comparison error

Blitz3D Forums/Blitz3D Programming/comparison error

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.

You can use integers if you want to do exact comparisons, floating point numbers by their nature will introduce rounding errors in most of the calculations in your test (difficult to see as Blitz3D rounds floats to 7 decimal places when it converts to strings for the purposes of printing etc.).

To use integers, you can use variables that store amounts in units of 1/1000ths, you just need to remember to divide any products by 1000 and insert your own decimal place when printing or use your trick where the string conversion is effectively rounding the inputs before the comparison.

If you have to do equality tests with floats you will need to compar the absolute difference of the two numbers with some sort of epsilon value.