Which of the following data types will allow the following code snippet to compile?
float i = 4;
float j = 2;
ˍˍˍˍˍ z = i + j;
Which of the following data types will allow the following code snippet to compile?
A. long
B. double
C. int
D. float
E. byte
題解
單精準浮點數(float)為 32 位元的浮點數,雙精準浮點數(double)為 64 位元的浮點數。由於 i 變數和 j 變數都是 32 位元的單精準浮點數,因此它們的運算結果也為 32 位元的單精準浮點數,也可以使用 64 位元的雙精準浮點數型態來儲存。所以 z 變數可以使用的資料型態為 float 和 double。
