C浮点数0x1.fp3

C floating point number 0x1.fp3

来自一篇文章:

"GNU CC recognizes floating-point numbers written not only in the usual decimal notation, such as 1.55e1, but also numbers such as 0x1.fp3 written in hexadecimal format. In that format the 0x hex introducer and the p or P exponent field are mandatory. The exponent is a decimal number that indicates the power of 2 by which the significand part will be multiplied. Thus 0x1.f is 1 15/16, p3 multiplies it by 8, and the value of 0x1.fp3 is the same as 1.55e1. "

似乎说 0x1.fp3 被计算为 = (1 + 15/16 ) * 2^3

15/16 从何而来?

既然是十六进制格式,那么0.1表示1/160.2表示2/16,...0.a表示10/16, ..., 0.f 表示 15/16.