[BASIC] Integer division \ operator limitation

Door sergarbes

Expert (114)

afbeelding van sergarbes

07-04-2022, 16:25

Hi all,

I am relearning MSX BASIC, to do so I amb developing a simple game with MSX BASIC. The point is that in the process I realize that the integer division only works for numbers between -32.768 and 32.767. Base on that I created a small routine to calculate the integer division by repeatedly subtracting the divisor from the dividend while the dividend is larger than the divisor.

Am I right about the limitation of the integer division operator \ in MSX BASIC?

Thanks in advance!

Aangemeld of registreer om reacties te plaatsen

Van ducasp

Hero (560)

afbeelding van ducasp

08-04-2022, 00:59

If I'm not mistaken, integer is using 2 bytes, so yes, it will be limited to those values...

Van sergarbes

Expert (114)

afbeelding van sergarbes

08-04-2022, 17:32

Thank you ducasp!

Van Amaury Carvalho

Resident (34)

afbeelding van Amaury Carvalho

09-04-2022, 15:38

Have you tried using the INT() function in normal division?

Something like that:

10 PRINT 100005 / 2
20 PRINT INT(100005 / 2)

Van sergarbes

Expert (114)

afbeelding van sergarbes

16-04-2022, 11:50

Thank you Amaury Carvalho, this is a better approach Tongue