when 10 to the power 10 is in the range of long, then why it is not taking the value without data type L?
Long data type , why not taking 10 to the power 10
Hii Utkarsh,
See when you initialize a long variable with value 10^10 without L at the end, 10^10 is interpretation as integer by the compiler but since the 10^10 is out of the range of int it gives error but when you add L it specifies the compiler that the no. is long .
Thanks, but when I define it by
long ln = 10 to the power 10;
Here when I have already defined data type as long still why I have to write L in the end?
I know but 10^10 is integer so compiler evaluate it as int data type as all the integers are evaluated as int type by the compiler by default but since it is beyond the range of int it shows you an error. By adding L at the end you tell compiler that it has to evaluate this no. as long data type.
Got it, thank you so much.