알고리즘/기초정리

숫자값이 너무 커서 int로는 커버가 안될 때

kimna-y 2016. 12. 20. 00:58
System.out.println((intMath.floor(4.4497083717E10));
System.out.println((long) Math.floor(4.4497083717E10));
System.out.println((long) 4.4497083717E10);
 
2147483647   -- due to an overflow
44497083717
44497083717



= 21413134219
= 19241313142
 
sum = (long) (Double.parseDouble(a) + Double.parseDouble(b));
 
sum = 40654447361



참고사이트

1. Floor function to float and double values

2. Formatting troubles: How to power to number?