Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Intellij long "integer value is too big" but in range of long.maxvalue

Integer number too large error

This might be a silly thing but how is this possible that compiler will show this while Long.Max = 9223372036854775807 ?

like image 488
vach Avatar asked Feb 03 '15 17:02

vach


1 Answers

You must have Long literals in Java ending with an L, adding an L to your integer will correct your issue, like so: Long s = 9223372036854775806L

This is because by default Java interprets all integers as 32-bit (int), the suffix L ensures that your integer is interpreted as 64-bit.

like image 88
HavelTheGreat Avatar answered Sep 19 '22 09:09

HavelTheGreat