How can I assign value of light year in meters in java to datatype, it seems it is too long.
For example:- 9,460,730,777,119,564 is value in mtrs for 1 light year
How can I assign value of light year in meters in java to datatype, it seems it is too long.
For example:- 9,460,730,777,119,564 is value in mtrs for 1 light year
The Long
datatype in standard java 2^63-1 digits, so the speed of light in meters should fit
You can use Long for it.
Long lightYearsInMeters = new Long("9460730777119564");
System.out.println(lightYearsInMeters);