明确地用base和exponent定义浮点值

maf*_*afu 5 c floating-point notation

我偶然发现了http://sourceware.org/ml/glibc-cvs/2013-q1/msg00115.html,其中包括该行

#define  TWO5      0x1.0p5      /* 2^5     */
Run Code Online (Sandbox Code Playgroud)

显然,TWO5被定义为带有显式值的double 1<<5.但是,这是我第一次看到这种表示法.这种格式是如何使用的,与写作相比有什么优势2.5

Lin*_*cer 6

这种表示法是在C99中引入的.优点是该值以十六进制形式表示,因此当您转换基础表示和小数形式之间的浮点值时,它不会发生舍入等.

有很多页面描述了这种表示法,例如:

http://www.exploringbinary.com/hexadecimal-floating-point-constants/