java 类型转换

93 阅读1分钟

Infinity 转换为long 9223372036854775807
double 1.0/0 等于Infinity

int a = 0;
int b = (byte) a + 46;
byte c = (byte) (a * b);
double f = (char) 1234.15;
long d = (long) (a + f / c + b);
System.out.println(d);
//        Infinity
System.out.println((1.0/0));

(byte)i 等于-128 ,(byte)i + f =-128+128.5=0.5, (int)0.5 =0 。

 float f = (float) 128.50;
 int i = (int) f;
 int b = (int) ((byte)i + f);

 System.out.println(b);

int 57 转换为 char 为9

(float) 500e-3 等于0.5