Problem with Mod command

BlitzMax Forums/BlitzMax Beginners Area/Problem with Mod command

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Why are these results different, and how can I get around it?
They aren't really different. The problem here is that IEEE Floating point aritmetic is attempting to fit an infinite series of numbers into a finite ammount of space (in this case 80 or 64 bits). Ofcourse this is impossible to do with absolute accuracy (if you can figure out otherwise you might just get a nobel prize).

As for a "way around it" use integer (CPU) instructions (^ is an FPU instruction) or rethink the algorithm. In your case this would be
Print 1 Shl (7-0)
b:Int = 0
Print 1 Shl (7-b)