알고리즘
[알고리즘-자바] 연산의 범위 (코드업 기초100제 1038,1039)
asong
2021. 1. 14. 19:41
입력하는 정수의 범위가 -1073741824 ~ 1073741824 일 경우: double을 입력받아 float로 출력하게 하였다.
double num1=sc.nextInt();
double num2=sc.nextInt();
System.out.printf("%.0f",num1+num2);
입력되는 정수의 범위가 -2147483648 ~ +2147483648 일 때,
long으로 입력받아 long으로 출력한다.
long num1=sc.nextLong();
long num2=sc.nextLong();
System.out.println(num1+num2);