문제해결
Integer.Min_Value 를 Math.abs 했을때
backend dev
2022. 12. 24. 14:05
System.out.println(Math.abs(Integer.MIN_VALUE));
이 코드를 실행시 -2147483648의 절대값인 2147483648가 나오지않는 이유는
int 형의 최대범위값이 +2147483647 이기 때문이다.
https://stackoverflow.com/questions/5444611/math-abs-returns-wrong-value-for-integer-min-value
Math.abs returns wrong value for Integer.Min_VALUE
This code: System.out.println(Math.abs(Integer.MIN_VALUE)); Returns -2147483648 Should it not return the absolute value as 2147483648 ?
stackoverflow.com