Re: [Ql-Users] Behaviour of DIV with negative numbers in SBASIC (QPC2)

2017-01-11 Thread Marcel Kilgus
John Alexander wrote:
> I'm sure it was written in C, I've not seen a dump of that about
> (is there one BTW??)

Why guess, the source code is available on the web. And it is
thousands upon thousands of lines of assembler code.

Marcel

___
QL-Users Mailing List


Re: [Ql-Users] Behaviour of DIV with negative numbers in SBASIC (QPC2)

2017-01-11 Thread John Alexander
I'm sure it was written in C, I've not seen a dump of that about (is there one 
BTW??) As such an assembly dump of the ROM would be quite different to what was 
originally written.
Could Tony enlighten us on that bit of history? 
Cheers John Alexander 

Sent from Yahoo Mail on Android 
 
  On Wed, 11 Jan, 2017 at 12:51, Marcel Kilgus wrote: 
  Tony Tebby wrote:
> If the divisor is negative, there is a problem. The "Euclidian division"
> definition requires that the remainder be between 0 and |divisor|-1. 
> This would seem to be a rather less than rigorous definition as 
> |divisor| is not a continuous function. In SBASIC the MOD function gives
> a remainder with the same sign as the divisor, which seemed, at the 
> time, to be more conventional, more logical and more useful. This forces
> the use of the "floored division" approach (second graph in the Wiki 
> article Modulo Operation) as described by Tobias. Floored division for
> DIV was not the choice, it was a consequence of the choice made for the
> MOD operation.
>
> Tony Tebby

Always good to hear the back-story to these things, thanks Tony! I've
fixed a minor bug in SBasic a few days ago and I'm simply amazed by
the amount of work that went into that code. Often I have a hard time
understanding halve of it, but I guess after all this time you
wouldn't fare much better? :-)

Cheers, Marcel

___
QL-Users Mailing List
  
___
QL-Users Mailing List

Re: [Ql-Users] Behaviour of DIV with negative numbers in SBASIC (QPC2)

2017-01-11 Thread Marcel Kilgus
Tony Tebby wrote:
> If the divisor is negative, there is a problem. The "Euclidian division"
> definition requires that the remainder be between 0 and |divisor|-1. 
> This would seem to be a rather less than rigorous definition as 
> |divisor| is not a continuous function. In SBASIC the MOD function gives
> a remainder with the same sign as the divisor, which seemed, at the 
> time, to be more conventional, more logical and more useful. This forces
> the use of the "floored division" approach (second graph in the Wiki 
> article Modulo Operation) as described by Tobias. Floored division for
> DIV was not the choice, it was a consequence of the choice made for the
> MOD operation.
>
> Tony Tebby

Always good to hear the back-story to these things, thanks Tony! I've
fixed a minor bug in SBasic a few days ago and I'm simply amazed by
the amount of work that went into that code. Often I have a hard time
understanding halve of it, but I guess after all this time you
wouldn't fare much better? :-)

Cheers, Marcel

___
QL-Users Mailing List


Re: [Ql-Users] Behaviour of DIV with negative numbers in SBASIC (QPC2)

2017-01-10 Thread Tony Tebby

On 05/01/2017 16:49, Tobias Fröschle wrote:

"S*Basic designers have chosen to use the "flooring" approach (round the floating 
point result to the next smaller number)"

This was some time ago but I don't think it is quite that. It is to do 
with the REMAINDER and not the result. For positive divisors, the 
remainder is defined to be in the range 0 to divisor-1 (the modulus) and 
the operation is defined to be reversible (quotient * divisor + 
remainder => original value of dividend). (Jan Jones is a 
mathematician). This does not correspond to the MC68000 instruction set 
definition that Martyn Hill seems to expect.


Viewed another way, Martyn Hill's expected result would twice as many 0 
quotients as any other value of quotient for a uniform distribution of 
dividends. This uneven distribution can be seen clearly as a 
discontinuity in top graph in the Wiki article Modulo Operation.


BUT !

If the divisor is negative, there is a problem. The "Euclidian division" 
definition requires that the remainder be between 0 and |divisor|-1. 
This would seem to be a rather less than rigorous definition as 
|divisor| is not a continuous function. In SBASIC the MOD function gives 
a remainder with the same sign as the divisor, which seemed, at the 
time, to be more conventional, more logical and more useful. This forces 
the use of the "floored division" approach (second graph in the Wiki 
article Modulo Operation) as described by Tobias. Floored division for 
DIV was not the choice, it was a consequence of the choice made for the 
MOD operation.


Tony Tebby

Martyn,

Integer division for negative numbers is not very well defined. Language designers get to 
choose if their language will round towards zero, negative infinity, or positive infinity 
when doing integer division. Different languages have made different choices. S*Basic 
designers have chosen to use the "flooring" approach (round the floating point 
result to the next smaller number).

Some other reasoning: -1 / 2 should be?
(1) -1/2 = 0 remainder -1
(2)$ ASR 1 = $ = -1

Another note: The original QL allowed word-size divisors and dividends. while 
SMSQ/E extended this to long integers. And the original QL manual even had an 
example illustrating what you see here:

-5 DIV 2 { will output -3}

Tobias



Am 05.01.2017 um 16:27 schrieb Martyn Hill :

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

___
QL-Users Mailing List



___
QL-Users Mailing List


Re: [Ql-Users] Behaviour of DIV with negative numbers in SBASIC (QPC2)

2017-01-09 Thread Bob Spelten
Op Mon, 09 Jan 2017 10:37:30 +0100 schreef George Gwilt  
:





On 9 Jan 2017, at 09:29, Jan Bredenbeek  wrote:

A word of warning!


It may be true that SMSQ/E supports Long INTs for DIV/MOD but I do
remember that QLIB does not.
I tried this in SQRview and it worked fine in SBasic but needed a
workaround for QLIB to avoid an "overflow" error.
It's possible that QLIB uses its own DIV/MOD routines.



This is also true for plain interpreted SuperBASIC. Only SBASIC supports
DIV/MOD with long INTs.


TURBO doesn’t.

For example 325 MOD 7 gives 5 in S*BASIC with QPC2, but overflow is  
reported by TURBO.



So there may still be a market for pjwitte's LDIV/LMOD.
That should work Qlib'd or Turbo'd.

Bob

--
The BSJR QL software site at: "http://members.upc.nl/b.spelten/ql/;
___
QL-Users Mailing List

Re: [Ql-Users] Behaviour of DIV with negative numbers in SBASIC (QPC2)

2017-01-09 Thread George Gwilt

> On 9 Jan 2017, at 09:29, Jan Bredenbeek  wrote:
> 
> A word of warning!
>> 
>> It may be true that SMSQ/E supports Long INTs for DIV/MOD but I do
>> remember that QLIB does not.
>> I tried this in SQRview and it worked fine in SBasic but needed a
>> workaround for QLIB to avoid an "overflow" error.
>> It's possible that QLIB uses its own DIV/MOD routines.
> 
> 
> This is also true for plain interpreted SuperBASIC. Only SBASIC supports
> DIV/MOD with long INTs.

TURBO doesn’t.

For example 325 MOD 7 gives 5 in S*BASIC with QPC2, but overflow is 
reported by TURBO.

George
___
QL-Users Mailing List

Re: [Ql-Users] Behaviour of DIV with negative numbers in SBASIC (QPC2)

2017-01-09 Thread Jan Bredenbeek
On 6 January 2017 at 17:07, Bob Spelten  wrote:

A word of warning!
>
> It may be true that SMSQ/E supports Long INTs for DIV/MOD but I do
> remember that QLIB does not.
> I tried this in SQRview and it worked fine in SBasic but needed a
> workaround for QLIB to avoid an "overflow" error.
> It's possible that QLIB uses its own DIV/MOD routines.


This is also true for plain interpreted SuperBASIC. Only SBASIC supports
DIV/MOD with long INTs.

-- 
*Jan Bredenbeek* | Hilversum, NL | j...@bredenbeek.net
___
QL-Users Mailing List


Re: [Ql-Users] Behaviour of DIV with negative numbers in SBASIC (QPC2)

2017-01-06 Thread pjwitte
Tobias, I just tested this against my own version of DIV/MOD and got 
these results:


100 CLS
110 DivMod 5, 2
120 DivMod -5, 2
130 DivMod -5, -2
140 DivMod 5, -2
150 :
160 DEFine PROCedure DivMod(a, b)
170 PRINT 'd'! a DIV b, 'm'! a MOD b, '='! a * (b DIV a) + b MOD a
180 PRINT 'D'! LDIV(a, b), 'M'! LMOD(a, b), '='! a * LDIV(b, a) + 
LMOD(b, a)\\

190 END DEFine
200 :

d 2 m 1 = 2
D 2 M 1 = 2

d -3m 1 = 2
D -2M -1= 2

d 2 m -1= -2
D 2 M -1= -2

d -3m -1= -2
D -2M 1 = -2

My LDIV/LMOD (written before the longword versions came out) works by 
removing the sign(s), then doing the division (based on an "algorithm" 
from an old mechanical calculator my grandfather used in the bank ;) 
and then adds back the sign(s) afterwards. Although the answers are 
somewhat different, using your formula below, the end result seems to 
be the same.


Per

(I sent this message 11 hours ago and it still hadnt arrived, so Ill 
try again. Apologies for any repetition)


On 06/01/2017 11:22, Tobias Fröschle wrote:

The "flooring" i.e. round down approach is normally chosen to make sure that

x = a *(x DIV a) + x MOD a

stays valid for negative numbers. That would not necessarily be the case if 
rounding towards 0.

Tobias


Am 05.01.2017 um 16:55 schrieb Martyn Hill :

Thank you Tobias!

Makes sense with that context.

M.

On 05/01/2017 15:49, Tobias Fröschle wrote:

Martyn,

Integer division for negative numbers is not very well defined. Language designers get to 
choose if their language will round towards zero, negative infinity, or positive infinity 
when doing integer division. Different languages have made different choices. S*Basic 
designers have chosen to use the "flooring" approach (round the floating point 
result to the next smaller number).

Some other reasoning: -1 / 2 should be?
(1) -1/2 = 0 remainder -1
(2)$ ASR 1 = $ = -1

Another note: The original QL allowed word-size divisors and dividends. while 
SMSQ/E extended this to long integers. And the original QL manual even had an 
example illustrating what you see here:

-5 DIV 2 { will output -3}

Tobias



Am 05.01.2017 um 16:27 schrieb Martyn Hill :

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

___
QL-Users Mailing List

--
"There are 10 types of people in this world. Those who understand binary and those 
who don't."

___
QL-Users Mailing List

___
QL-Users Mailing List



___
QL-Users Mailing List

Re: [Ql-Users] Behaviour of DIV with negative numbers in SBASIC (QPC2)

2017-01-06 Thread Tobias Fröschle
Yep.

Same is true for the Turbo compiler.

Tobias

> Am 06.01.2017 um 17:07 schrieb Bob Spelten :
> 
> Op Thu, 05 Jan 2017 16:49:09 +0100 schreef Tobias Fröschle 
> >:
> 
>> Martyn,
>> 
>> Integer division for negative numbers is not very well defined. Language 
>> designers get to choose if their language will round towards zero, negative 
>> infinity, or positive infinity when doing integer division. Different 
>> languages have made different choices. S*Basic designers have chosen to use 
>> the "flooring" approach (round the floating point result to the next smaller 
>> number).
>> 
>> Some other reasoning: -1 / 2 should be?
>> (1) -1/2 = 0 remainder -1
>> (2)$ ASR 1 = $ = -1
>> 
>> Another note: The original QL allowed word-size divisors and dividends. 
>> while SMSQ/E extended this to long integers. And the original QL manual even 
>> had an example illustrating what you see here:
>> 
>> -5 DIV 2 { will output -3}
>> 
> A word of warning!
> 
> It may be true that SMSQ/E supports Long INTs for DIV/MOD but I do remember 
> that QLIB does not.
> I tried this in SQRview and it worked fine in SBasic but needed a workaround 
> for QLIB to avoid an "overflow" error.
> It's possible that QLIB uses its own DIV/MOD routines.
> 
> Bob
> 
> -- 
> The BSJR QL software site at: "http://members.upc.nl/b.spelten/ql/ 
> "
> ___
> QL-Users Mailing List

___
QL-Users Mailing List

Re: [Ql-Users] Behaviour of DIV with negative numbers in SBASIC (QPC2)

2017-01-06 Thread Bob Spelten
Op Thu, 05 Jan 2017 16:49:09 +0100 schreef Tobias Fröschle  
:



Martyn,

Integer division for negative numbers is not very well defined. Language  
designers get to choose if their language will round towards zero,  
negative infinity, or positive infinity when doing integer division.  
Different languages have made different choices. S*Basic designers have  
chosen to use the "flooring" approach (round the floating point result  
to the next smaller number).


Some other reasoning: -1 / 2 should be?
(1) -1/2 = 0 remainder -1
(2)$ ASR 1 = $ = -1

Another note: The original QL allowed word-size divisors and dividends.  
while SMSQ/E extended this to long integers. And the original QL manual  
even had an example illustrating what you see here:


-5 DIV 2 { will output -3}


A word of warning!

It may be true that SMSQ/E supports Long INTs for DIV/MOD but I do  
remember that QLIB does not.
I tried this in SQRview and it worked fine in SBasic but needed a  
workaround for QLIB to avoid an "overflow" error.

It's possible that QLIB uses its own DIV/MOD routines.

Bob

--
The BSJR QL software site at: "http://members.upc.nl/b.spelten/ql/;
___
QL-Users Mailing List


Re: [Ql-Users] Behaviour of DIV with negative numbers in SBASIC (QPC2)

2017-01-06 Thread pjwitte
Tobias, I just tested this against my own version of DIV/MOD and got 
these results:


100 CLS
110 DivMod 5, 2
120 DivMod -5, 2
130 DivMod -5, -2
140 DivMod 5, -2
150 :
160 DEFine PROCedure DivMod(a, b)
170 PRINT 'd'! a DIV b, 'm'! a MOD b, '='! a * (b DIV a) + b MOD a
180 PRINT 'D'! LDIV(a, b), 'M'! LMOD(a, b), '='! a * LDIV(b, a) + 
LMOD(b, a)\\

190 END DEFine
200 :

d 2 m 1 = 2
D 2 M 1 = 2

d -3m 1 = 2
D -2M -1= 2

d 2 m -1= -2
D 2 M -1= -2

d -3m -1= -2
D -2M 1 = -2

My LDIV/LMOD (written before the longword versions came out) works by 
removing the sign(s), then doing the division (based on an "algorithm" 
from an old mechanical calculator my grandfather used in the bank ;) 
and then adds back the sign(s) afterwards. Although the answers are 
somewhat different, using your formula below, the end result seems to 
be the same.


Per

On 06/01/2017 11:22, Tobias Fröschle wrote:

The "flooring" i.e. round down approach is normally chosen to make sure that

x = a *(x DIV a) + x MOD a

stays valid for negative numbers. That would not necessarily be the case if 
rounding towards 0.

Tobias


Am 05.01.2017 um 16:55 schrieb Martyn Hill :

Thank you Tobias!

Makes sense with that context.

M.

On 05/01/2017 15:49, Tobias Fröschle wrote:

Martyn,

Integer division for negative numbers is not very well defined. Language designers get to 
choose if their language will round towards zero, negative infinity, or positive infinity 
when doing integer division. Different languages have made different choices. S*Basic 
designers have chosen to use the "flooring" approach (round the floating point 
result to the next smaller number).

Some other reasoning: -1 / 2 should be?
(1) -1/2 = 0 remainder -1
(2)$ ASR 1 = $ = -1

Another note: The original QL allowed word-size divisors and dividends. while 
SMSQ/E extended this to long integers. And the original QL manual even had an 
example illustrating what you see here:

-5 DIV 2 { will output -3}

Tobias



Am 05.01.2017 um 16:27 schrieb Martyn Hill :

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

___
QL-Users Mailing List

--
"There are 10 types of people in this world. Those who understand binary and those 
who don't."

___
QL-Users Mailing List

___
QL-Users Mailing List



___
QL-Users Mailing List

Re: [Ql-Users] Behaviour of DIV with negative numbers in SBASIC (QPC2)

2017-01-06 Thread Tobias Fröschle
The "flooring" i.e. round down approach is normally chosen to make sure that 

x = a *(x DIV a) + x MOD a 

stays valid for negative numbers. That would not necessarily be the case if 
rounding towards 0.

Tobias

> Am 05.01.2017 um 16:55 schrieb Martyn Hill :
> 
> Thank you Tobias!
> 
> Makes sense with that context.
> 
> M.
> 
> On 05/01/2017 15:49, Tobias Fröschle wrote:
>> Martyn,
>> 
>> Integer division for negative numbers is not very well defined. Language 
>> designers get to choose if their language will round towards zero, negative 
>> infinity, or positive infinity when doing integer division. Different 
>> languages have made different choices. S*Basic designers have chosen to use 
>> the "flooring" approach (round the floating point result to the next smaller 
>> number).
>> 
>> Some other reasoning: -1 / 2 should be?
>> (1) -1/2 = 0 remainder -1
>> (2)$ ASR 1 = $ = -1
>> 
>> Another note: The original QL allowed word-size divisors and dividends. 
>> while SMSQ/E extended this to long integers. And the original QL manual even 
>> had an example illustrating what you see here:
>> 
>> -5 DIV 2 { will output -3}
>> 
>> Tobias
>> 
>> 
>>> Am 05.01.2017 um 16:27 schrieb Martyn Hill :
>>> 
>>> 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
>> ___
>> QL-Users Mailing List
> 
> -- 
> "There are 10 types of people in this world. Those who understand binary and 
> those who don't."
> 
> ___
> QL-Users Mailing List

___
QL-Users Mailing List

Re: [Ql-Users] Behaviour of DIV with negative numbers in SBASIC (QPC2)

2017-01-05 Thread Martyn Hill

Thank you Tobias!

Makes sense with that context.

M.

On 05/01/2017 15:49, Tobias Fröschle wrote:

Martyn,

Integer division for negative numbers is not very well defined. Language designers get to 
choose if their language will round towards zero, negative infinity, or positive infinity 
when doing integer division. Different languages have made different choices. S*Basic 
designers have chosen to use the "flooring" approach (round the floating point 
result to the next smaller number).

Some other reasoning: -1 / 2 should be?
(1) -1/2 = 0 remainder -1
(2)$ ASR 1 = $ = -1

Another note: The original QL allowed word-size divisors and dividends. while 
SMSQ/E extended this to long integers. And the original QL manual even had an 
example illustrating what you see here:

-5 DIV 2 { will output -3}

Tobias



Am 05.01.2017 um 16:27 schrieb Martyn Hill :

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

___
QL-Users Mailing List


--
"There are 10 types of people in this world. Those who understand binary and those 
who don't."

___
QL-Users Mailing List


Re: [Ql-Users] Behaviour of DIV with negative numbers in SBASIC (QPC2)

2017-01-05 Thread Tobias Fröschle
Martyn,

Integer division for negative numbers is not very well defined. Language 
designers get to choose if their language will round towards zero, negative 
infinity, or positive infinity when doing integer division. Different languages 
have made different choices. S*Basic designers have chosen to use the 
"flooring" approach (round the floating point result to the next smaller 
number).

Some other reasoning: -1 / 2 should be? 
(1) -1/2 = 0 remainder -1
(2)$ ASR 1 = $ = -1 

Another note: The original QL allowed word-size divisors and dividends. while 
SMSQ/E extended this to long integers. And the original QL manual even had an 
example illustrating what you see here:

-5 DIV 2 { will output -3}

Tobias


> Am 05.01.2017 um 16:27 schrieb Martyn Hill :
> 
> 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

___
QL-Users Mailing List