At 21:19 19/06/2001 +0100, you wrote:
>> Hmmm - the odd behaviour with negative numbers is not unique to SBASIC.
>> I've just tried it with QBASIC in NT and it does exactly the same.
>> I'd be interested to read the ISO or ANSI standard on this for the
>> justification. Curiously, the 68040 provides two instructions for
>> getting an integer from a float: FINT allows user specified rounding,
>> e.g. 'round-to-nearest', while FINTRZ always does 'round-to-zero'. I
>> still can't see the usefulness in having INT(-3.01)=-4 though. Any
>> mathematicians care to comment?
It's a matter of consistency; mathematicians love consistency !
Consider the number 3.01 as a point on the real number line. It is a
point .01 to the right of the left boundary of the region 3 -> 4.
INT(3.01) takes the left boundary, 3, as its value.
Now, consider the number -3.01. It may be written as -4 + .99, i.e.,
it is a point .99 to the right of the left boundary of the region -4
-> -3. INT(-3.01) takes the left boundary, -4, as its value. Consistency !
However, if what you _really_ want is the _nearest_ integer, use INT(x + .5).
<big snip>
>BTW, my (Classic) JM QL gives INT(-3.1) => -4. This is one case where
>the manual gets it wrong; it states: "INT will return the integer part
>of the specified floating point expression."
Also my JSU QL & SMSQE. The Sinclair manual is correct only for
positive numbers but see "The SBASIC/SuperBASIC Reference Manual" by
Rich Mellor et al for the proper statement.
>
>Robert
>