View Full Version : Numeric variables (decimal issue)
I encountered a little "issue" (well it isnt really one) and I don´t know how to overcome it...
I need exact position data and therefor I need variables which dont get round up or down. Is there any possibility to define how many decimal numbers after the koma are used by a variable or how to turn off the rounding completly?
Jun 9 2009, 03:49
I'm not sure if I understand the problem correctly. But there are many math (http://community.bistudio.com/wiki/Category:Command_Group:_Math) commands that deal with number rounding in the usual ways.
To define i.e 2 numbers behind the comma, you can multiply by 100, do a round or integer on it, then divide it by 100 again.
Note that you can come to experience a weird 'computer bug' if you're dealing with 'extraction of numbers' this way. Due to the way processors work behind the comma, you could end up with a situation where 0.7*10 isn't 7, but 6.9999999999998 (not tested, just a generic example). Doing an int operation here causes the result to be 6 which naturally is way off.
Not sure if this is applicable, but it has caused me some nightmares in the past before I was made aware of it.
Jun 9 2009, 04:25
MoS, I suggest you find another way to do what you want to do.
It looks like the engine still uses single precision floating-point numbers (aka "floats"). So the numbers in ARMA have at least 6 significant digits and a magnitude between about 10^-38 and 10^38.
Dealing with floating-point numbers is a special kind of fun most people don't really enjoy:
player sideChat str (3.402823 * 10^38); // 3.40282e+038
player sideChat str (3.402824 * 10^38); // 1.#INF (exceeds max. float)
player sideChat str (sqrt(2)^2); // 2
player sideChat str (sqrt(2)^2 == 2); // FALSE
player sideChat str (2^24 == 2^24 + 1); // TRUE
If you are truly determined you should read this document (http://docs.sun.com/source/806-3568/ncg_goldberg.html).
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.