[Date Index] [Thread Index] [Author Index]
Re: Unexpected behavior of Floor and IntegerPart
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.