Re: bug in IntegerPart ?
- To: mathgroup at smc.vnet.net
- Subject: [mg47754] Re: bug in IntegerPart ?
- From: Bill Rowe <readnewsciv at earthlink.net>
- Date: Sun, 25 Apr 2004 05:13:26 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
On 4/24/04 at 4:15 AM, lang.NO at science.uva.nl (Dennis de Lang) wrote: >Why does the following happen? >In:= (1.65 - 1.3)/0.007 >Out:= 50. >In:= IntegerPart[%] >Out:= 49 >but: >In:= 0.35/0.007 >Out:= 50. >In:= IntegerPart[%] >Out:= 50 This is a result of machine precision arithmetic. The issue arises becuase numbers like 0.35 do not have a finite binary expansion. So, the number that is used for such numbers will either be the closest binary number or a binary number that has been truncated compared to the true value. So, what happens in the first example is 1.65 and 1.3 are converted to machine numbers. The difference between these two machine numbers is slightly less than .35 as demonstrated by: In= Log[10, 35/100 - (1.65 - 1.3)] Out= -15.9546 You can get similar results for other combinations of machine numbers giving results near the threshold of a function such as IntegerPart -- To reply via email subtract one hundred and four