Hi everyone

Can anyone tell me the expected behaviour for the integer-divide operator 'DIV' in SBASIC, when provided with a negative dividend/numerator?

My number-theory is a bit rusty, but I would have thought that, say, -1 DIV 10 should result in 0 (with remainder/MOD of -1).

Instead, on QPC2/SBASIC, I get the result -1 for that example - and (almost) always 1 less than expected for negative dividends, thus:

 12 DIV 10 = 1
 11 DIV 10 = 1
 10 DIV 10 = 1
   9 DIV 10 = 0
...
   2 DIV 10 = 0
   1 DIV 10 = 0
   0 DIV 10 = 0
* -1 DIV 10 = -1 - expected '0'**
** -2 DIV 10 = -1**
**...**
**  -9 DIV 10 = -1*
*-10 DIV 10 = -1 - as expected*
*-11 DIV 10 = -2 - expected '-1'
-12 DIV 10 = -2

*etc...

Thanks in advance!

Martyn.
_______________________________________________
QL-Users Mailing List

Reply via email to