???Bug in Int()-function of ACC95 and ACC97 ??? 
Author Message
 ???Bug in Int()-function of ACC95 and ACC97 ???

Hello,
 who can help me with my int()-function problem...
Is there a bug in the int()-function??? When there is a bug, I think I have
a little problem, because I used it very often in ACC95 and 97...

To understand my problem please try the following small functions and please
wonder Yourself when You let them run in the debug-window...

1) please try this:

Function test()
Dim amt As Double
Dim inttest As Long
amt = 1014.3
inttest = Int(amt * 10)
Debug.Print inttest
End Function

in the debug-window :
test
 10142   'whats that????????
_______________________
2) Then try this:

Function test()
Dim amt As Double
Dim inttest As Long
amt = 3550.3
inttest = Int(amt * 10)
Debug.Print inttest
End Function

in the debug-window :
test
 35503            'That is ok, I think
_____________
3) And now look at this:

Function test()
Dim amt, amt1 As Double
Dim inttest, inttest1 As Long
amt = 1014.3
amt1 = 3550.3
inttest = Int(amt * 10)
inttest1 = Int(amt1 * 10)
Debug.Print inttest
Debug.Print inttest1
End Function

in the debug-window :
test
 10143   'Why is that now ok??????
 35503    'What is that now??????????
___________
4) And now I can only wonder:

Function test()
Dim amt, amt1 As Double   ' You do only declare amt1
Dim inttest As Long
amt = 1014.3
inttest = Int(amt * 10)
Debug.Print inttest
End Function

in the debug-window :
test
 10143        ' And that is now ok, but why?????????



Tue, 19 Mar 2002 03:00:00 GMT  
 ???Bug in Int()-function of ACC95 and ACC97 ???
Thanks for Your answer,
what You say, I think, is right...
Annother solution I tested is to use a new variable like this:
Dim hlpint as long
hlpint = amt * 10
inttest = Int(hlpint)
This, I tested, worked...

But I cannot understand, that the two examples below do not work
synchrone...
Here I declare in 2) only a new variable (amt1), which I do not use for the
int()-function and the rest is the same code... I think, that is a little
bit strange or not?
1)
Function test1()
Dim amt As Double
Dim inttest As Long
amt = 1014.3
inttest = Int(amt * 10)
Debug.Print inttest
End Function
in the debug-window :
test1
 10142   'whats that????????

2)
Function test2()
Dim amt, amt1 As Double   ' You do only declare amt1
Dim inttest As Long
amt = 1014.3
inttest = Int(amt * 10)
Debug.Print inttest
End Function
in the debug-window :
test2
 10143        ' And that is now ok, but why?????????

Rainer



Quote:
> The problem arises because floating point numbers can
> be inaccurate due to limited precision and binary-decimal
> conversions. But Int() is exact. This isn't a bug.

> In most cases this can be solved by wrapping the inaccurate
> result in CDec(), like in

>     inttest = Int(CDec(amt * 10))

> Many times CCur() can be used instead, but it handles only
> 4 decimals.

> --
> Paul


> >Hello,
> > who can help me with my int()-function problem...
> >Is there a bug in the int()-function??? When there is a bug, I think I
have
> >a little problem, because I used it very often in ACC95 and 97...



Tue, 19 Mar 2002 03:00:00 GMT  
 ???Bug in Int()-function of ACC95 and ACC97 ???
I tried your first function (copy and paste) and my result was correct: 10143
Beats me.

Pawel

1)
Function test1()
    Dim amt As Double
    Dim inttest As Long
    amt = 1014.3
    inttest = Int(amt * 10)
    Debug.Print inttest
End Function

Quote:

> Thanks for Your answer,
> what You say, I think, is right...
> Annother solution I tested is to use a new variable like this:
> Dim hlpint as long
> hlpint = amt * 10
> inttest = Int(hlpint)
> This, I tested, worked...

> But I cannot understand, that the two examples below do not work
> synchrone...
> Here I declare in 2) only a new variable (amt1), which I do not use for the
> int()-function and the rest is the same code... I think, that is a little
> bit strange or not?
> 1)
> Function test1()
> Dim amt As Double
> Dim inttest As Long
> amt = 1014.3
> inttest = Int(amt * 10)
> Debug.Print inttest
> End Function
> in the debug-window :
> test1
>  10142   'whats that????????

> 2)
> Function test2()
> Dim amt, amt1 As Double   ' You do only declare amt1
> Dim inttest As Long
> amt = 1014.3
> inttest = Int(amt * 10)
> Debug.Print inttest
> End Function
> in the debug-window :
> test2
>  10143        ' And that is now ok, but why?????????

> Rainer



> > The problem arises because floating point numbers can
> > be inaccurate due to limited precision and binary-decimal
> > conversions. But Int() is exact. This isn't a bug.

> > In most cases this can be solved by wrapping the inaccurate
> > result in CDec(), like in

> >     inttest = Int(CDec(amt * 10))

> > Many times CCur() can be used instead, but it handles only
> > 4 decimals.

> > --
> > Paul


> > >Hello,
> > > who can help me with my int()-function problem...
> > >Is there a bug in the int()-function??? When there is a bug, I think I
> have
> > >a little problem, because I used it very often in ACC95 and 97...



Wed, 20 Mar 2002 03:00:00 GMT  
 ???Bug in Int()-function of ACC95 and ACC97 ???

The True and nothing but the true.

But if you need to convert to Int, use

CInt(amt * 10)    'round 10142.999999999 to 10143

instead of

Int(amt * 10)   ' truncate 10142.999999999 to 10142

---------------------------------------------------------------------

Get paid to read adverti{*filter*}ts by e-mail in www.sendmoreinfo.com
Worried about spam? Open a free autoforward account in Lycos.
---------------------------------------------------------------------


  The problem arises because floating point numbers can
  be inaccurate due to limited precision and binary-decimal
  conversions. But Int() is exact. This isn't a bug.

  In most cases this can be solved by wrapping the inaccurate
  result in CDec(), like in

      inttest = Int(CDec(amt * 10))

  Many times CCur() can be used instead, but it handles only
  4 decimals.

  --
  Paul


  >Hello,
  > who can help me with my int()-function problem...
  >Is there a bug in the int()-function??? When there is a bug, I think I have
  >a little problem, because I used it very often in ACC95 and 97...
  >



Sat, 23 Mar 2002 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Open Dialog Boxes, difference in Acc95 and Acc97.

2. Bug when ising INT function

3. BUG: VB4(16 bit) - Int and Fix functions don't work correctly

4. Advanced : Function for Add-In ACC95

5. TERRIBLE BUG IN INT FUNCION???????????????????

6. Bug in Int() and Numbers

7. BUG?? Weird Int rounding

8. Converting BitArray to Int and Int to BitArray

9. How to display int, short int range values

10. Int to Str or Str to Int ??

11. Converting ULONG (4 byte binary) int VB Long / SQL INT for DTS Import

12. Convert Int to Str & Str to Int

 

 
Powered by phpBB® Forum Software