我在 libgcc 中阅读了一些代码:
UDWtype __fixunsxfDI (XFtype a)
{
if (a < 0)
return 0;
/* Compute high word of result, as a flonum. */
const XFtype b = (a / Wtype_MAXp1_F);
/* Convert that to fixed (but not to DWtype!),
and shift it into the high word. */
UDWtype v = (UWtype) b;
v <<= W_TYPE_SIZE;
/* Remove high part from the XFtype, leaving the low part as flonum. */
a -= (XFtype)v;
/* Convert that to fixed (but not to DWtype!) and add it in.
Sometimes A comes out negative. This is significant, since
A has more bits than a long int does. */
if (a < 0)
v -= (UWtype) (- a);
else
v += (UWtype) a;
return v;
}
关于 XFType:
typedef float XFtype __attribute__ ((mode (XF)));
关于Wtype_MAXp1_F:</p>
#if W_TYPE_SIZE == 8
# define Wtype_MAXp1_F 0x1p8f
#elif W_TYPE_SIZE == 16
# define Wtype_MAXp1_F 0x1p16f
#elif W_TYPE_SIZE == 32
# define Wtype_MAXp1_F 0x1p32f
#elif W_TYPE_SIZE == 64
# define Wtype_MAXp1_F 0x1p64f
#else
# error "expand the table"
#endif
我认为 XFType 是 96 位浮点数,而 0x1p32f 是 1^32。
什么是
const XFtype b = (a / Wtype_MAXp1_F)
方法 ?