类型转换时候,编译器是如何具体实现的?
package a0319v01;
public class a0319v01 {
public static void main (String[] args){
int score1 = 82;
double score2 = score1;
int score3 = (int)score2;
System.out.println("score1 = "+score1);
System.out.println("score2 = "+score2);
System.out.println("score3 = "+score3);
}
}
运行结果显示:
score1 = 82
score2 = 82.0
score3 = 82
请问,在编译 double score2 = score1; 这条语句时候,编译器是具体怎样进行的?为何score1类型转换后值没变?而后面强制类型转换 int score3 = (int)score2; 时候,score2内存里的数是如何让进行取舍,或者编译时候如何取整的?