Loading ...
Sorry, an error occurred while loading the content.

34507Re: MOD

Expand Messages
  • Richard Russell
    Aug 1, 2007
    • 0 Attachment
      --- In libertybasic@yahoogroups.com, "Nick Fraser" wrote:
      > How come the following code:
      > [snip]
      > produces the following as an output?
      >
      > 2.0 1.0 0.5 1

      Most BASIC dialects convert both arguments to integers before
      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.

      Richard.
    • Show all 9 messages in this topic