Math Isnt Working

BlitzMax Forums/BlitzMax Programming/Math Isnt Working

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.

I found the problem. Blitz uses the formula Exp(y * Log(x)) to find x^y. The problem is that Log() and Exp() work on doubles and floating point numbers are subject to rounding errors. If you make calc a float, you'll see that it calculates 2^3 to 7.9999999 which when converted to int, becomes 7. If you change the program to read
Local calc = (2^num)+.5

Then the result will be correct.