Java에서 int를 float로 변환하면 다음 예제 코드와 같이 정밀도가 손실 될 수 있습니다.Java에서는 int를 float로 암시 적으로 변환 할 수 있습니다. 왜?
public class Test {
public static void main(String [] args) {
int intVal = 2147483647;
System.out.println("integer value is " + intVal);
double doubleVal = intVal;
System.out.println("double value is " + doubleVal);
float floatVal = intVal;
System.out.println("float value is " + floatVal);
}
}
정밀도의 손실이있을 때 출력은,
integer value is 2147483647
double value is 2.147483647E9
float value is 2.14748365E9
떠 INT의 암시 적 변환을 허용 뒤에 이유는 무엇입니까
입니까?
중복 http://stackoverflow.com/questions/11183980/why-does-c-sharp-allow-an-implicit-conversion-from-long-to-float-when-this-co –
@ AaronKurtzhals : 그 질문은 다른 언어에 관한 것입니다. – Wug