[BASIC] Integer division \ operator limitation

Par sergarbes

Expert (116)

Portrait de 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!

!login ou Inscrivez-vous pour poster

Par ducasp

Paladin (712)

Portrait de 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...

Par sergarbes

Expert (116)

Portrait de sergarbes

08-04-2022, 17:32

Thank you ducasp!

Par Amaury Carvalho

Resident (41)

Portrait de 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)

Par sergarbes

Expert (116)

Portrait de sergarbes

16-04-2022, 11:50

Thank you Amaury Carvalho, this is a better approach Tongue