OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: Unnamed on 25 Apr 2004, 00:11:57
-
Hi,
I want to get all the numbers following a decimal point. Trouble is I have to do some subtraction first, which is where I come unstuck:
In an ideal world:
500.4 - 500=0.4
But in OFP it goes more like:
500.4 - 500=0.399994
and...
500.7 - 500=0.700012
500.8 - 500=0.799988
Any ideas how to get sensible results back from these subtractions?
Cheers
-
lo unnamed,
You're right - 500.4 - 500 = 0.3994996 (or so :D )
But:
hint format ["%1",(((500.4 * 10) - (500 *10)) / 10)]
gave me a result of: 0.4
P.S: not sure wether multiplicating a number by a factor of 10
is enough in case of bigger numbers (or higher values behind the comma), but i'm pretty sure that the higher the factor gets,
the higher the accuracy of the result will be.
~S~ CD
-
not sure wether multiplicating a number by a factor of 10
is enough in case of bigger numbers (or higher values behind the comma), but i'm pretty sure that the higher the factor gets,
the higher the accuracy of the result will be.
Yeah just move everything to the left of the decimal, so you avoid the problem. I can get everything to the left Ok.
The range of numbers will be no higher than .999 , I can do some If statements to check if I need to multiply & divide by 10, 100 or 1000.
Thanks Chris :)