Jump to content
Sign in to follow this  

Max useable integer in SQF?

Recommended Posts

Hi all, I read though




and the only somewhat direct mention of this was, under Consequences (regarding Floating-point Precision):



Large numbers can not always be incremented / decremented. For example, 87654320 + 1 returns 87,654,320 in Arma 3 (the next larger floating-point number after 87,654,320 is 87,654,328).


Anyone ever determine the actual largest integer that Arma 3 can handle as an integer (meaning + 1 or - 1 works)?


I ran this little test:

(and after narrowing things down a bit)

//_num = 20000000; // Immediate Problem!
//_num = 19000000; // Immediate Problem!
//_num = 18000000; // Immediate Problem!
//_num = 17000000; // Immediate Problem!
_num = 16000000; // No (immediate) problem... ran for perhaps 1-2 minutes so far... can't wait around all day and watch this though...
waitUntil {
	["_num"] call MRU_Chat;
	_numX = _num;
	_num = _num + 1;
	if (_num == _numX) exitWith {
		systemChat "This _num was a problem! (for + 1)";

Seems the true limit is... somewhere between 16-17 million?



In case anyone is wondering... I need this for my Terrain Scanner and AI system (ids for cells and portals).  I just figured out how to break some long-standing limits and scan larger swaths of terrain in parallel... 😉


Share this post

Link to post
Share on other sites

Incrementing by one works up to 16777216 (2^24), the next valid number is 16777218, as 16777217 cannot be represented. From this point onward you will experience missing integer values.


The largest value is 3.4028235 * 10^38 (340282346638528860000000000000000000000) but at that point gaps between numbers aren't 1 or 2 or even 1000000, they're more like 10^32.


There is a chart on wikipedia that shows how accuracy degrades as value increases: https://en.wikipedia.org/wiki/IEEE_754#/media/File:IEEE754.svg

You can see the blue line crosses floating point precision = 10^0 at floating point value around 10^7 which is consistent with what we see in SQF.

  • Like 3
  • Thanks 1

Share this post

Link to post
Share on other sites

Awesome, makes perfect sense now.  Very well said & many thanks!  I'll put this to use immediately.


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