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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Rounding Problems 1

Status
Not open for further replies.

tryn2learn

Programmer
Jun 26, 2000
24
0
0
US
Help, this is making no sense! I’m having a problem with the round() function. I’m running visual 6.0. My code is like the following where salary is a variable (N 10 2) and fields a, b & c are all defined as numeric 10 2

Select a, b, c from table one into cursor query
Amount = query.a + ((query.b /100) * (salary – query.c))
Rnd_amt = round(amount,2)

However, if amount = 279.77500000 then the result of rnd_amt comes out as 279.77! But, sometimes it will work. For instance, if amount is 76.97500000 the rnd_amt comes out as 76.98, which is what I expect. If the thousandths position is a 6 it rounds up each time, but when it is a 5 it seems to me that it depends on the phase of the moon or something!

My set decimals is set to 8. Rnd_amt is initialized to 0.00000000
 
Evbcs
Try the following:

? VAL(STR( round(75397.275,2),11,2)) produces 75397.28
? VAL(STR( round(75397.2750000000,2),11,2)) produces 75397.27
[ponder]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top