[BASIC] Integer division \ operator limitation

By sergarbes

Expert (114)

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!

ログイン/登録して投稿

By ducasp

Hero (550)

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 (114)

sergarbes さんの画像

08-04-2022, 17:32

Thank you ducasp!

By Amaury Carvalho

Rookie (31)

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 (114)

sergarbes さんの画像

16-04-2022, 11:50

Thank you Amaury Carvalho, this is a better approach Tongue