- Aug 1, 2007--- In firstname.lastname@example.org, "Nick Fraser" wrote:
> How come the following code:Most BASIC dialects convert both arguments to integers before
> produces the following as an output?
> 2.0 1.0 0.5 1
performing the MOD operation, and in that case 'MOD 2' can only ever
return the values zero (0) and one (1). That's certainly true of
the other BASICs I've tried (BASICA, QBasic, BBC BASIC).
However strictly speaking you can define MOD for non-integer
arguments and it would appear that Liberty Basic does so.
Therefore, using the definition that MOD returns the remainder after
a division, the results you are seeing are to be expected (allowing
for the fact that 1.9999999999 is rounded up to 2.0 for display).
So, LB is unusual in working that way, but arguably not incorrect.
- << Previous post in topic Next post in topic >>