package Collection; public class PrimitiveType { public static void main(String[] args) { // TODO Auto-generated method stub float f=5.45321562154655215f;//定义float类型后面必须加f float f1=5.2354f; //对比两个输出结果之间的差异 float f2=54222.4541564664f; float f3=574841154.021f; System.out.println(f); System.out.println(f1); System.out.println(f2); System.out.println(f3); /* * 5.4532156 5.2354 54222.453 5.7484115E8 经过对比我们发现如果float输出不超过8位 数字E8表示乘以科学计算法 */ } }
package Collection; public class PrimitiveDouble { public static void main(String[] args) { // TODO Auto-generated method stub double d1=23518811455.5144; double d2=2.5; System.out.println(d1); System.out.println(d2); } //2.35188114555144E10 //2.5 //此时double可以不带d; }
package Collection; public class PrimitiveDouble { public static void main(String[] args) { System.out.println(3.2f/0); System.out.println(-3.2f/0); //Infinity 正无穷大 // -Infinity 负无穷大 } //Infinity 正无穷大 // -Infinity 负无穷大 }
时间: 2024-10-10 14:22:53