# Apex Double datatype takes any big value?

I was trying to check the type conversion rules. When I am testing integr and Long are not accepting the values more than the range for example 2147483648 and 9223372036854775808L respectivly will make error for integr and long while assignment. But the interesting thing Double as per salesforce is `"A 64-bit number that includes a decimal point. Doubles have a minimum value of -263 and a maximum value of 263-1"`. Below code is running without showing an error

``````Double l = 92233720368547758079999999999999999999999999.0;
Double i = l + 1;
System.debug(i);
``````

But

``````    Long l = 9223372036854775808L;
Long i = l + 1;
System.debug(i);
``````

Is as per documentation and throws error since 9223372036854775808 is 1 more than the range.

So my question is why Double accepts any big number?

• Two to the power 63 i.e. 2 * 2 * 2 and so on 63 times is a very big number. Commented Mar 29, 2014 at 16:55
• Unfortunately, there is no double long in Apex. Commented Mar 29, 2014 at 23:21

This got me curious

Using this code in V29:

``````Double d = 2.0;
Double exp = 1024.0;
d = System.Math.pow(d, exp);
system.debug(logginglevel.info,'d='+d);
``````

That is 2 to the 1024th; yields this debug line:

``````14:27:31.034 (34940000)|SYSTEM_METHOD_ENTRY|[3]|system.Math.pow(Double, Double)
14:27:31.035 (35004000)|SYSTEM_METHOD_EXIT|[3]|system.Math.pow(Double, Double)
14:27:31.035 (35013000)|SYSTEM_MODE_EXIT|false
14:27:31.035 (35036000)|VARIABLE_ASSIGNMENT|[3]|d|Infinity
``````

That is, 2 to the 1024th is `Infinity` !

And values smaller than this are not infinity ( I looped through 2^256 to 2^1024).

``````14:39:40.085 (85260000)|USER_DEBUG|[7]|INFO|2 to the 1020.0 = 1.1235582092889474E307
14:39:40.085 (85320000)|USER_DEBUG|[7]|INFO|2 to the 1021.0 = 2.247116418577895E307
14:39:40.085 (85379000)|USER_DEBUG|[7]|INFO|2 to the 1022.0 = 4.49423283715579E307
14:39:40.085 (85441000)|USER_DEBUG|[7]|INFO|2 to the 1023.0 = 8.98846567431158E307
14:39:40.085 (85493000)|USER_DEBUG|[7]|INFO|2 to the 1024.0 = Infinity
``````

I also verified that a Double of 2^1023 -1 is not equal to a Double of 2^1023 so internally, the precision is present up to 2^1024 -1

Note that 2^1024 = 179769313486231590772930519078902473361797697894230657273430081157732675805500963132708477322407536021120113879871393357658789768814416622492847430639474124377767893424865485276302219601246094119453082952085005768838150682342462881473913110540827237163350510684586298239947245938479716304835356329624224137216 (source)

I would say the doc is wrong