Re: Unexpected behavior of Floor and IntegerPart
- To: mathgroup at smc.vnet.net
- Subject: [mg97909] Re: Unexpected behavior of Floor and IntegerPart
- From: Bill Rowe <readnews at sbcglobal.net>
- Date: Wed, 25 Mar 2009 05:44:54 -0500 (EST)
On 3/24/09 at 5:32 AM, cfo at lanl.gov (Curtis Osterhoudt) wrote: >I'm sure this is a result of non-infinite-precision arithmetic, but >it would be nice to have a more consistent behavior: >In:= IntegerPart[0.29*100] >Out= 28 <more tests/examples snipped> Yes, the behavior you are seeing is due to using machine precision numbers. If by consistent you mean you want consistency between the results obtained using machine precision numbers and exact numbers that isn't possible. The difference is an aspect of the way computers are designed and work. This difference can be overcome by Mathematica either by converting the machine precision numbers to exact numbers or increasing the precision beyond machine precision. Of course there is a cost to increasing precision in terms of performance time.