Re: Unexpected behavior of Floor and IntegerPart
- To: mathgroup at smc.vnet.net
- Subject: [mg97908] Re: Unexpected behavior of Floor and IntegerPart
- From: Bill Rowe <readnews at sbcglobal.net>
- Date: Wed, 25 Mar 2009 05:44:43 -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[26]:= IntegerPart[0.29*100] >Out[26]= 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.