[BASIC] Integer division \ operator limitation

By sergarbes

Expert (116)

Аватар пользователя 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

By ducasp

Paladin (712)

Аватар пользователя 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...

By sergarbes

Expert (116)

Аватар пользователя sergarbes

08-04-2022, 17:32

Thank you ducasp!

By Amaury Carvalho

Resident (41)

Аватар пользователя 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)

By sergarbes

Expert (116)

Аватар пользователя sergarbes

16-04-2022, 11:50

Thank you Amaury Carvalho, this is a better approach Tongue