Java中是怎么确定double的长度?

比如double(32,5)包括小数点的长度最大可以输入多少个字节。好像int(9)就可以是9个字节。那么double(32,5)呢?

你是想 输出的时候 来控制 要输出小数点后面的几位还是 想知道 double 的最大长度?
1、
public static void fun(){
double cc = 9098.08876;
DecimalFormat aa = new DecimalFormat(".#"); // 几个# 就是要几位小数
System.out.println(aa.format(cc));
}

2、 double.MAX_VALUE 最大长度
温馨提示:答案为网友推荐,仅供参考
第1个回答  2013-03-29
int最大就能存4个字节呀,double是双精度浮点类型的,共64位,它没有存储限制,浮点类型的包括小数,float类型也和double一样,没有规范它的界限,double(32.5)到底是是多少个字节,你试试转换byte数字试试吧。
第2个回答  2013-03-28
汗,这个是java中规定的长度么
/**
* A constant holding the largest positive finite value of type
* <code>double</code>,
* (2-2<sup>-52</sup>)·2<sup>1023</sup>. It is equal to
* the hexadecimal floating-point literal
* <code>0x1.fffffffffffffP+1023</code> and also equal to
* <code>Double.longBitsToDouble(0x7fefffffffffffffL)</code>.
*/
public static final double MAX_VALUE = 1.7976931348623157e+308; // 0x1.fffffffffffffP+1023
/**
* A constant holding the smallest positive nonzero value of type
* <code>double</code>, 2<sup>-1074</sup>. It is equal to the
* hexadecimal floating-point literal
* <code>0x0.0000000000001P-1022</code> and also equal to
* <code>Double.longBitsToDouble(0x1L)</code>.
*/
public static final double MIN_VALUE = 4.9e-324; // 0x0.0000000000001P-1022

看double的包装类,就知道它最大,最小值了本回答被网友采纳
第3个回答  推荐于2018-05-13
double float数据类型,计算机中表示实型变量的一种变量类型。此数据类型与单精度数据类型(float)相似,但精确度比float高,编译时所占的内存空间依不同的编译器而有所不同,通常情况,单精度浮点数占4字节(32位)内存空间,其数值范围为3.4E-38~3.4E+38,;双精度型占8 个字节(64位)内存空间,其数值范围为1.7E-308~1.7E+308。
声明double 类型的变量:
double puotient;
初始化double 类型的变量:
puotient = 5.621456873;
double puotinet = 5.62;

以下是java中double的包装类代码
/**
* A constant holding the largest positive finite value of type
* <code>double</code>,
* (2-2<sup>-52</sup>)·2<sup>1023</sup>. It is equal to
* the hexadecimal floating-point literal
* <code>0x1.fffffffffffffP+1023</code> and also equal to
* <code>Double.longBitsToDouble(0x7fefffffffffffffL)</code>.
*/
public static final double MAX_VALUE = 1.7976931348623157e+308; // 0x1.fffffffffffffP+1023
/**
* A constant holding the smallest positive nonzero value of type
* <code>double</code>, 2<sup>-1074</sup>. It is equal to the
* hexadecimal floating-point literal
* <code>0x0.0000000000001P-1022</code> and also equal to
* <code>Double.longBitsToDouble(0x1L)</code>.
*/
public static final double MIN_VALUE = 4.9e-324; // 0x0.0000000000001P-1022本回答被网友采纳
第4个回答  2013-03-28
谁教你int(9)就是9字节!