Floatting numbers dont add right...

Blitz3D Forums/Blitz3D Programming/Floatting numbers dont add right...

Why is easy, computers cannot store floating point numbers exactly - unless it is a half (.5, .25, .125, etc...) and blitz only uses single precision floating point. Double precision would get it closer.

How to handle it. If you are only doing addition and subtraction with 2 decimal precision, store the number as integers and just show them with 2 decimal places when outputing.

If you need to do multiplication it gets trickier. Another possability is to store them as floating point, but when doing condditional tests write them as

x <= Y-.5 and x<Y+.5 instead of x = y (that handles the precision differences, although the .5 could vary)