Page MenuHomeFeedback Tracker

Large numbers cannot be used properly in arithmetic operations.
Closed, ResolvedPublic

Description

I stumbled on this while making a mission which regularly deals with large numbers (the costs related to war) in it's calculations. The problem appears when you work with numbers > 16777216.

16777217 and above combined operators like % or == will give you some weird results. These are the only 2 operators I've managed to confirm as having this issue due to the fact that numbers are converted to scientific notation when converted into strings or put into the rpt-file.

Script file containing 2 tests that show the problem.
https://dl.dropboxusercontent.com/u/74011028/bug.sqf

According to the community wiki on the data type Number (http://community.bistudio.com/wiki/Number) the game is supposed to be able to atleast manage very large numbers

Details

Legacy ID
2342279314
Severity
None
Resolution
Open
Reproducibility
Always
Category
Scripting
Steps To Reproduce

Test 1

  1. Place yourself in editor and preview.
  2. Paste the following line into the debug console and hit exec.

player sideChat str (16777216 == 16777217);

Test 2
Run this:
diag_log text "------------------ Start -------------------";
diag_log text format ["16777209 mod 1000 = %1", 16777209 mod 1000];
diag_log text format ["16777210 mod 1000 = %1", 16777210 mod 1000];
diag_log text format ["16777211 mod 1000 = %1", 16777211 mod 1000];
diag_log text format ["16777212 mod 1000 = %1", 16777212 mod 1000];
diag_log text format ["16777213 mod 1000 = %1", 16777213 mod 1000];
diag_log text format ["16777214 mod 1000 = %1", 16777214 mod 1000];
diag_log text format ["16777215 mod 1000 = %1", 16777215 mod 1000];
diag_log text format ["16777216 mod 1000 = %1", 16777216 mod 1000];
diag_log text "------------------ Fault line -------------------";
diag_log text format ["16777217 mod 1000 = %1", 16777217 mod 1000];
diag_log text format ["16777218 mod 1000 = %1", 16777218 mod 1000];
diag_log text format ["16777219 mod 1000 = %1", 16777219 mod 1000];
diag_log text format ["16777220 mod 1000 = %1", 16777220 mod 1000];
diag_log text format ["16777221 mod 1000 = %1", 16777221 mod 1000];
diag_log text format ["16777222 mod 1000 = %1", 16777222 mod 1000];
diag_log text format ["16777223 mod 1000 = %1", 16777223 mod 1000];
diag_log text format ["16777224 mod 1000 = %1", 16777224 mod 1000];
diag_log text "------------------ End -------------------";

Event Timeline

mrCurry edited Steps To Reproduce. (Show Details)Aug 12 2013, 11:29 PM
mrCurry edited Additional Information. (Show Details)
mrCurry set Category to Scripting.
mrCurry set Reproducibility to Always.
mrCurry set Severity to None.
mrCurry set Resolution to Open.
mrCurry set Legacy ID to 2342279314.May 7 2016, 3:59 PM
Bohemia added a subscriber: ceeeb.Aug 12 2013, 11:29 PM

16 777 215 = 0xFFFFFF

here is your answer FFFFFF must be the largest number you can have.

Actually this is not true but, congrats on bringing this up:

According to wiki: http://community.bistudio.com/wiki/Number

testing:

hint str 3.4028235e38 => 3.40282e+038
hint str 3.4028236e38 => 1.#INF

16777215 is 1.67772e+007 way less than 3.4028235e38

999999 seems to be the largest int you can have before it starts getting all wierd on you and failing

ceeeb added a comment.Aug 13 2013, 7:20 AM

Arma uses single precision floating point numbers, which have limited precision (generally six figures AFAIK). Any real number used by scripts in game is stored in memory as the closest possible floating point number.

see http://en.wikipedia.org/wiki/Single_precision

MadDogX added a subscriber: MadDogX.May 7 2016, 3:59 PM

Mass closing ancient tickets with no activity for > 12 months; assume fixed or too trivial.

If this issue is still relevant in current dev build, please re-post.