MOD bug

Previous topic - Next topic

bigsofty

Very large numbers cause MOD to return negative numbers...

Code (glbasic) Select
PRINT MOD(3124987331, 100), 30,30...for example.

The number is not out of bounds but its close, I don't know if that's where the problem lies.
Cheers,

Ian.

"It is practically impossible to teach good programming style to students that have had prior exposure to BASIC.  As potential programmers, they are mentally mutilated beyond hope of regeneration."
(E. W. Dijkstra)

Kitty Hello

oh no. Do you really, really need this?

bigsofty

Well, it showed up in Hash table alogorithms... I had to insert  " (unsigned int) bigfloatvar % 100" as a inline to work around it...
Cheers,

Ian.

"It is practically impossible to teach good programming style to students that have had prior exposure to BASIC.  As potential programmers, they are mentally mutilated beyond hope of regeneration."
(E. W. Dijkstra)

Schranz0r

What about INLINE...
I <3 DGArray's :D

PC:
AMD Ryzen 7 3800X 16@4.5GHz, 16GB Corsair Vengeance LPX DDR4-3200 RAM, ASUS Dual GeForce RTX™ 3060 OC Edition 12GB GDDR6, Windows 11 Pro 64Bit, MSi Tomahawk B350 Mainboard

Kitty Hello

that's what he did.
The problem is: when the number is negative, (unsigned int)n%m returns a wrong number. That might explain it. Also: The gp2x/pocketpc devices use 32bit floats only -> here you get this error much earlier. Please try to avoid these large numbers if possible.

bigsofty

Quote from: GernotFrischthat's what he did.
The problem is: when the number is negative, (unsigned int)n%m returns a wrong number. That might explain it. Also: The gp2x/pocketpc devices use 32bit floats only -> here you get this error much earlier. Please try to avoid these large numbers if possible.
Good to know, Ill add a note in the source and check it, when I get to the pocket PC version. ;)
Cheers,

Ian.

"It is practically impossible to teach good programming style to students that have had prior exposure to BASIC.  As potential programmers, they are mentally mutilated beyond hope of regeneration."
(E. W. Dijkstra)