From: Mark Hubbart Date: 2005-04-01T05:52:23+09:00 Subject: Re: Integer/Float oddity On Fri, 1 Apr 2005 04:23:00 +0900, Steven Jenkins wrote: > michael.b.masi@gmail.com wrote: > > [snip] > > i'm assuming that since this behaviour is exhibited in ruby and the > > rest of the above "other languages" and NOT xbasic that it is really > > due to an idiosyncracy of xbasic that the "right" answer comes out. > > > > so the question becomes, what is different about xbasic's internal > > numeric representation that allows it to give a correct answer to this > > seemingly simple number manipulation? > > Nothing. It's just that Xbasic (apparently) defines INT() to mean > "closest integer" and some other languages define it to mean "largest > integer not exceeding". Both give results consistent with their > definitions. Either one gives you what you need to round *or* truncate. > > round(x) is equivalent to truncate(x + .5) Still, one is considered the standard (which can be translated as "correct"), and the other isn't. The standardized behavior is to truncate, if you count on that and it rounds, your computations are not going to come out the same. IIRC, the IEEE standard for floating point numbers specifies how they should be converted to integers. cheers, Mark