GLBasic forum

Main forum => Bug Reports => Topic started by: bigsofty on 2008-Mar-07

Title: MOD bug
Post by: bigsofty on 2008-Mar-07
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.
Title: MOD bug
Post by: Kitty Hello on 2008-Mar-07
oh no. Do you really, really need this?
Title: MOD bug
Post by: bigsofty on 2008-Mar-07
Well, it showed up in Hash table alogorithms... I had to insert  " (unsigned int) bigfloatvar % 100" as a inline to work around it...
Title: MOD bug
Post by: Schranz0r on 2008-Mar-07
What about INLINE...
Title: MOD bug
Post by: Kitty Hello on 2008-Mar-08
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.
Title: MOD bug
Post by: bigsofty on 2008-Mar-08
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. ;)