Jump to content
Sign in to follow this  
MoS

Numeric variables (decimal issue)

Recommended Posts

Hi

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?

Share this post


Link to post
Share on other sites

I'm not sure if I understand the problem correctly. But there are many 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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×