MathGroup Archive 2004

[Date Index] [Thread Index] [Author Index]

Search the Archive

RE: bug in IntegerPart ?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg47753] RE: [mg47736] bug in IntegerPart ?
  • From: "DrBob" <drbob at bigfoot.com>
  • Date: Sun, 25 Apr 2004 05:13:25 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

There's NO reason to be puzzled. 1.65 and 1.3 can't be represented exactly
in binary, so of course their difference may not be exact, either. Hence the
division problems have different numerators.

RealDigits[0.35, 2]
{{1, 0, 1, 1, 0, 0, 1, 1, 0, 
   0, 1, 1, 0, 0, 1, 1, 0, 0, 
   1, 1, 0, 0, 1, 1, 0, 0, 1, 
   1, 0, 0, 1, 1, 0, 0, 1, 1, 
   0, 0, 1, 1, 0, 0, 1, 1, 0, 
   0, 1, 1, 0, 0, 1, 1, 0}, 
  -1}
RealDigits[1.65 - 1.3, 2]
{{1, 0, 1, 1, 0, 0, 1, 1, 0, 
   0, 1, 1, 0, 0, 1, 1, 0, 0, 
   1, 1, 0, 0, 1, 1, 0, 0, 1, 
   1, 0, 0, 1, 1, 0, 0, 1, 1, 
   0, 0, 1, 1, 0, 0, 1, 1, 0, 
   0, 1, 1, 0, 0, 1, 0, 0}, 
  -1}

DrBob

www.eclecticdreams.net


-----Original Message-----
From: Dennis de Lang [mailto:lang.NO at science.uva.nl] 
To: mathgroup at smc.vnet.net
Subject: [mg47753] [mg47736] bug in IntegerPart ?

Why does the following happen?

In[1]:= (1.65 - 1.3)/0.007
Out[1]:= 50.
In[2]:= IntegerPart[%]
Out[2]:= 49

but:

In[1]:= 0.35/0.007
Out[1]:= 50.
In[2]:= IntegerPart[%]
Out[2]:= 50

I'm puzzled....
- Dennis





  • Prev by Date: Re: bug in IntegerPart ?
  • Next by Date: Re: bug in IntegerPart ?
  • Previous by thread: Re: bug in IntegerPart ?
  • Next by thread: Re: bug in IntegerPart ?