The real
types store the binary representation of a sign (+ or -), an exponent,
and a significand. A real value has the form
+/- significand * 2^exponent
where the significand has a single
bit to the left of the binary decimal point. (That is, 0 <= significand
< 2.)
In the figures that follow, the most significant bit is always on the left and the least significant bit on the right. The numbers at the top indicate the width (in bits) of each field, with the leftmost items stored at the highest addresses. For example, for a Real48 value, e is stored in the first byte, f in the following five bytes, and s in the most significant bit of the last byte.
A 6-byte (48-bit) Real48 number is divided into three fields:
|
1 |
39 |
8 |
|
s |
f |
e |
If 0 <
e <= 255, the value v of the number is given by
v = (-1)^s * 2^(e-129) * (1.f)
If e
= 0, then v = 0.
The Real48 type can’t store denormals, NaNs, and infinities. Denormals become zero when stored in a Real48, while NaNs and infinities produce an overflow error if an attempt is made to store them in a Real48.
A 4-byte (32-bit) Single number is divided into three fields
|
1 |
8 |
23 |
|
s |
e |
f |
The value
v of the number is given by
if 0 <
e < 255, then v = (-1)^s * 2^(e-127) * (1.f
)
if e
= 0 and f <> 0, then v = (-1)^s * 2^(-126) * (0.f
)
if e
= 0 and f = 0, then v = (-1)^s * 0
if e
= 255 and f = 0, then v = (-1)^s * Inf
if e = 255 and f <> 0, then v is a NaN
An 8-byte (64-bit) Double number is divided into three fields
|
1 |
11 |
52 |
|
s |
e |
f |
The value
v of the number is given by
if 0 <
e < 2047, then v = (-1)^s * 2^(e-1023) * (1.f
)
if e
= 0 and f <> 0, then v = (-1)^s * 2^(-1022) * (0.f
)
if e
= 0 and f = 0, then v = (-1)^s * 0
if e
= 2047 and f = 0, then v = (-1)^s * Inf
if e = 2047 and f <> 0, then v is a NaN
A 10-byte (80-bit) Extended number is divided into four fields:
|
1 |
15 |
1 |
63 |
|
s |
e |
i |
f |
The value
v of the number is given by
if 0
<= e < 32767, then v = (-1)^s * 2^(e-16383) *
(i.f )
if e
= 32767 and f = 0, then v = (-1)^s * Inf
if e = 32767 and f <> 0, then v is a NaN
An 8-byte (64-bit) Comp number is stored as a signed 64-bit integer.
An 8-byte (64-bit) Currency number is stored as a scaled and signed 64-bit integer with the four least-significant digits implicitly representing four decimal places.
实数类型存储符号(+ 或 -)、指数(exponent)和有效数字(significand)的二进制表示。实数值具有如下形式
+/- significand * 2^exponent
where the significand has a single bit to the left of the binary decimal point. (That is, 0 <= significand < 2.)
这里,significand有一个单独位(比特)在二进制小数点左边(即0 <= significand < 2)。
在下面的表中,大多数有效位总是在左边而少数在右边。表格上方的数字表示每个片段的宽度(以比特位为单位),最左边的项存储在最高的地址。例如,对于一个Real48值,e存储在第一个字节,f在接下来的五个字节,而s在最后一个字节中的最有效位。
6字节(48位)的Real48数字被分为三段:
|
1 |
39 |
8 |
|
s |
f |
e |
如果0 < e <= 255,那么数字的值 v 为
v = (-1)^s * 2^(e-129) * (1.f)
如果 e = 0,那么v = 0。
Real48类型不能存储不规范值、NaN(非数字)值和无穷大。当存储一个不规范值到Real48中时,它将变成零,而试图存储NaN值和无穷大到Real48中时将导致溢出错误。
4字节(32位)的Single数字被分为三段:
|
1 |
8 |
23 |
|
s |
e |
F |
数字的值 v 为
如果 0 < e < 255,那么v = (-1)^s * 2^(e-127) *
(1.f )
如果 e = 0 且 f <> 0,那么v = (-1)^s * 2^(-126) * (0.f
)
如果 e = 0且f = 0,那么v = (-1)^s * 0
如果 e = 255且f = 0,那么v = (-1)^s * Inf
如果 e = 255且f <> 0,那么v 是一个NaN
8字节(64位)的Double数字被分为3段:
|
1 |
11 |
52 |
|
s |
e |
f |
数字的值 v 为
如果 0 < e < 2047,那么 v = (-1)^s * 2^(e-1023) *
(1.f )
如果 e = 0 且 f <> 0,那么
v = (-1)^s * 2^(-1022) *
(0.f )
如果 e = 0 且 f = 0,那么 v = (-1)^s * 0
如果 e = 2047 且f = 0,那么 v = (-1)^s * Inf
如果 e = 2047 且 f <> 0,那么 v 是一个NaN
10字节(80位)的Extended数字被分为四段:
|
1 |
15 |
1 |
63 |
|
s |
e |
i |
f |
数字的值 v 为
如果 0 <= e < 32767,那么 v = (-1)^s * 2^(e-16383) *
(i.f )
如果 e = 32767 且 f = 0,那么 v = (-1)^s * Inf
如果 e = 32767 且 f <> 0,那么 v 是一个NaN
8字节(64位)的Comp数字作为含符号的64位整数存储。
8字节(64位)的Currency数字被存储为按比例的、含符号的64位整数,它有四个最少的有效数字隐含表示四个十进制位。
编者注
NaN即非数字(Not a Number)。