Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Rounding off numbers

Status
Not open for further replies.

Tweetiepie

Programmer
Jul 13, 2001
7
GB
Hi, I am using SQL server with a Visual Basic frontend. If i enter in a number say 2.5 it saves ok and then when i go to retrieve the value it comes back as 2.499999999998. Is there any way i can get this to stay as 2.5 as it is causing alot of resouces to be used up when i have to perform calculations on the values.. If i was to round it off it would also peopbably use up alot of resources tooo. Is there a way i could program it to automatically leave it the way it was entered or rounded off as soon as it is entered?
Any ideas would be apreciated.
Thanks a million
 

Use datatype Decimal or Numeric rather than Float or Real. Float and Real are approximate numbers. Decimal and Numeric data type will store exact values. Terry Broadbent
Please review faq183-874.

"The greatest obstacle to discovery is not ignorance -- it is the illusion of knowledge." - Daniel J Boorstin
 
I checked through the table defintions and the datatype is set at varchar of 255. Does the properties of varchar round off numbers. I know that they do truncate blank strings.
Thanks a million
 
Hi Tweetiepie,
It seems that your problem exist in the way you are transfering data to sql. Just check in debug window that what is the actual sql string you are executing for insert.

If possible, send us also value of sqlstring, which you find in debug window.
 
heya i'm not actually using an insert statement. What i am doing is using a select query and creating a recordset with teh results of the select query. Then using a the value of the field for the text box.. i.e.
txtProduct.text = .fields("product").value

is this what is causing the problem.It is not all the time that i am getting the above problem,so i assumed there is no problem in my method.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top