2023-java-study / book-study

북 스터디 기록 레포지토리
0 stars 0 forks source link

[Item 59] Math.abs() 와 Integer.MIN_VALUE #149

Open gmelon opened 1 year ago

gmelon commented 1 year ago
System.out.println(Integer.MIN_VALUE); // -2147483648
System.out.println(Math.abs(Integer.MIN_VALUE)); // -2147483648

System.out.println(Integer.MAX_VALUE + 1); // -2147483648

이렇게 사용하면 오버플로우로 인한 현상이 발생하네요. 알아두면 좋을 것 같아용