Jump to content
ins3821

BIS_fnc_numbertext negative number scientific notation

Recommended Posts

Hi everyone
i have an issue making a simple economy function in my mission.
 

i want write negative number using to BIS_fnc_numbertext.
when i use negative number then this function show me scientific notation.

BIS_fnc_numbertext use reason is scientific notation.

 

here my code.
plz help...

befor_basicbudget = 0;
basicbudget_killciv = 30000;
culclear = 10000;

_getculmoney = profileNamespace getVariable "befor_basicbudget";

systemchat format["$ %1 collection",[basicbudget_killciv * culclear] call BIS_fnc_numberText];

after_basicbudget = _getculmoney - basicbudget_killciv;
            
profileNamespace setVariable ["befor_basicbudget", after_basicbudget];

systemchat format["$ %1",[after_basicbudget * culclear] call BIS_fnc_numberText];

 

Share this post


Link to post
Share on other sites

https://en.wikipedia.org/wiki/Single-precision_floating-point_format#Precision_limitations_on_integer_values

 

Basically, your numbers are too large.

 

Change your base values to something like 

befor_basicbudget = 0;
basicbudget_killciv = 30007;
culclear = 10007;

and you'll see that it returns a rounded value rather than a precise value (rounded up to 300 280 064  instead of the correct 300 280 049).

 

Not sure why the negative value is returning in scientific, though.

 

KK created a function to deal with very large numbers, specifically in the context of an economy, have a look here:  http://killzonekid.com/arma-scripting-tutorials-arithmetic-library/

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites
21 hours ago, Harzach said:

https://en.wikipedia.org/wiki/Single-precision_floating-point_format#Precision_limitations_on_integer_values

 

Basically, your numbers are too large.

 

Change your base values to something like 


befor_basicbudget = 0;
basicbudget_killciv = 30007;
culclear = 10007;

and you'll see that it returns a rounded value rather than a precise value (rounded up to 300 280 064  instead of the correct 300 280 049).

 

 Not sure why the negative value is returning in scientific, though.

 

KK created a function to deal with very large numbers, specifically in the context of an economy, have a look here:  http://killzonekid.com/arma-scripting-tutorials-arithmetic-library/


ok i try it

 

thank you

Share this post


Link to post
Share on other sites

Use toFixed command (alternative syntax), like this:

 

tofixed 0;
befor_basicbudget = 0;
basicbudget_killciv = 30007;
culclear = 10007;
_getculmoney = profileNamespace getVariable "befor_basicbudget";
 systemchat format["$ %1 collection",basicbudget_killciv * culclear];
 after_basicbudget = _getculmoney - basicbudget_killciv;
profileNamespace setVariable ["befor_basicbudget", after_basicbudget];
 systemchat format["$ %1",after_basicbudget * culclear];

 

Result:

$ 300280064 collection

$ -300280064

 

Not sure you'd can gain in precision with Arma engine.

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites
4 hours ago, pierremgi said:

toFixed

 

I was going to mention it, but it didn't address the rounding issue. I should have, though, as it was added several years after KK posted that function.

  • Like 1
  • Thanks 1

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

×