Rounding Problem? 
Author Message
 Rounding Problem?

I'm getting a math error in Access.  It appears to be a problem in
A97, A2000, and AccessXP.

1.  Go to an immediate window
2.  Type the following expression:  
      ? INT( 100000 * 4.1)

The answer I get every time is: 409999

Unless I'm mistaken, the answer should be  410000

Does anyone see a problem with this?



Sun, 10 Apr 2005 08:57:10 GMT  
 Rounding Problem?
As per John's explanation, try:

? Round( 100000 * 4.1)
 410000

in A2K & AXP.

HTH
Van T. Dinh
MVP (Access)


Quote:

> I'm getting a math error in Access.  It appears to be a problem in
> A97, A2000, and AccessXP.

> 1.  Go to an immediate window
> 2.  Type the following expression:
>       ? INT( 100000 * 4.1)

> The answer I get every time is: 409999

> Unless I'm mistaken, the answer should be  410000

> Does anyone see a problem with this?



Sun, 10 Apr 2005 10:18:51 GMT  
 Rounding Problem?


Quote:

>I'm getting a math error in Access.  It appears to be a problem in
>A97, A2000, and AccessXP.

>1.  Go to an immediate window
>2.  Type the following expression:  
>      ? INT( 100000 * 4.1)

>The answer I get every time is: 409999

>Unless I'm mistaken, the answer should be  410000

>Does anyone see a problem with this?

Only a problem with expectation.

Floating point numbers, such as 4.1, are stored internally as binary
fractions times an exponent. As such, they are approximations (just as
3.1415926535 is an approximation to pi, or 0.142856 is an
approximation to 1/7).

The Int() function is rounding down. The stored approximation to 4.1
is evidently just a tiny bit less than 4.1, and the rounding is biting
you.

                  John W. Vinson[MVP]    
    Come for live chats every Tuesday and Thursday
http://go.compuserve.com/msdevapps?loc=us&access=public



Sun, 10 Apr 2005 09:20:11 GMT  
 Rounding Problem?
Thanks.  I thought it might be something like that.

On Tue, 22 Oct 2002 19:20:11 -0600, John Vinson

Quote:



>>I'm getting a math error in Access.  It appears to be a problem in
>>A97, A2000, and AccessXP.

>>1.  Go to an immediate window
>>2.  Type the following expression:  
>>      ? INT( 100000 * 4.1)

>>The answer I get every time is: 409999

>>Unless I'm mistaken, the answer should be  410000

>>Does anyone see a problem with this?

>Only a problem with expectation.

>Floating point numbers, such as 4.1, are stored internally as binary
>fractions times an exponent. As such, they are approximations (just as
>3.1415926535 is an approximation to pi, or 0.142856 is an
>approximation to 1/7).

>The Int() function is rounding down. The stored approximation to 4.1
>is evidently just a tiny bit less than 4.1, and the rounding is biting
>you.

>                  John W. Vinson[MVP]    
>    Come for live chats every Tuesday and Thursday
>http://go.compuserve.com/msdevapps?loc=us&access=public



Mon, 11 Apr 2005 23:29:27 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. specific round problem, please help

2. Rounding problems with Access

3. rounding problem, help a beginner please

4. Generic rounding problem??

5. Rounding problems...

6. rounding problem

7. Rounding Problems

8. VB 4 Rounding Problem

9. Rounding Problem

10. Rounding problem with SQL Server Decimal(38,15) data type when data is pulled in to Excel PivotTables?

11. Strange rounding problem - What's wrong with this code?

12. Rounding problem with SQL Server Decimal(38,15) data type when data is pulled in to Excel PivotTables?

 

 
Powered by phpBB® Forum Software