Java中的数字问题
来源:互联网 发布:美元指数软件 编辑:程序博客网 时间:2024/04/30 04:56
public class Volume {
public static void main(String args[]) {
double sunDiameter = 86500000d;//若数字不加d,则最后的结果不同,为什么?
double sunRadius = sunDiameter / 2;
double earthDiameter = 760000d;
double earthRadius = earthDiameter / 2;
double sunVolume;
double earthVolume;
double ratio;
sunVolume = 4d / 3d * (Math.PI) * sunRadius * sunRadius * sunRadius;//若数字不加d,则最后的结果不同,为什么?
earthVolume = 4d / 3d * (Math.PI) * earthRadius * earthRadius
* earthRadius;
ratio = sunVolume / earthVolume;
System.out.println(sunDiameter);
System.out.println(sunRadius);
System.out.println(earthDiameter);
System.out.println(earthRadius);
System.out.println(sunVolume);
System.out.println(earthVolume);
System.out.println(ratio);
System.out.println("The volume of the Earth is " + earthVolume
+ " cubic miles" + " and the volume of the Sun is " + sunVolume
+ " cubic miles"
+ " and the ratio of the volume of the Sun to "
+ "the volume of the Earth is " + ratio);
}
}
- Java中的数字问题
- Java中的数字基本运算和精度问题
- Java中的数字基本运算和精度问题
- Java中的数字基本运算和精度问题
- Java中的数字基本运算和精度问题
- Java中的数字基本运算和精度问题
- java中的数字格式化
- java中的数字处理
- java中的数字格式化
- Java中的数字处理
- freemarker 数字输出中的逗号问题,${temp}为空问题,时间问题(Java中Date)
- AS3中的数字运算问题
- 矩阵中的数字连通问题
- java 截取括号中的数字
- java中的数字精确计算
- java 获取String中的数字
- Java去除字符串中的数字
- java 获取String中的数字
- strcpy 和 strncpy的区别
- StarWest 2010 - Day 0 - Travel
- MFC(Visual C++ 6.0)中使用文件流fstream的相关问题
- PE文件导入表
- 修正版本的磁盘监控.. 整合到一个脚本算了.方便
- Java中的数字问题
- el表达式和jstl标签
- 第二章(契约 双向操作)
- DBI接口与DPI接口与DSI接口
- SD卡家族
- resources在“Resources”参数中指定了多次。“Resources”参数不支持重复项。
- RFC1334——PPP Authentication Protocols中文版
- ice php与java传递对像与数组
- SDIO