From: Steven Jenkins Date: 2005-04-01T06:17:43+09:00 Subject: Re: Integer/Float oddity Mark Hubbart wrote: >>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. I don't think it does. IEEE 754 specifies how rounding is applied in floating-point calculations, but does not define an API. No standard requires *every* language to have an operator called INT() that truncates. (C doesn't, for example.) Absent that, Xbasic can define INT() however it wants. You might wish they'd chosen differently, but that doesn't make it wrong. Also note that ISO C defines various math library functions (e.g., floor()), but does not mandate IEEE 754 compliance. Steve