I am new to Java programming. I am calculating the travel speed in a specific distance, but when I get to trillions, I'm not sure what to do.
I've already tried putting 'L' on the last part of the value, however, I also remember that long data type is limited to 4 trillion so I'm getting this error:
Error:(22, 58) java: illegal character: '\u202c'
double speed = 299792;
long distance= 41320000000000L;
long temp = distance/speed;
I was expecting the result to be 137828894.70. But I only get the error. I've been searching for answers since yesterday and I got no solution to this.
EDIT
I was able to figure things out, thank you for everyone's help! My code is now working and as follows:
BigDecimal distance= new BigDecimal("41320000000000");
BigDecimal speed = new BigDecimal("299792");
BigDecimal travelSpeed = distance.divide(speed, BigDecimal.ROUND_HALF_UP);