问题描述
正在转换固定铂。 (固定n比特为分数)到IEEE双重安全吗?ie:确实IEEE双格式可以表示一个固定点可以表示的所有数字吗?
测试:一个数字转为浮动pt格式,然后返回到原来的固定pt格式。 p>假设你的定点数是以32位整数存储的,那么IEEE双精度可以表示任何以固定点表示的值。这是因为double有一个53位的尾数,你的定点值只有32位的精度,而定点值的浮点指数在-32到32之间(取决于你认为的二进制点的位置在你的定点值),这是在可以表示的范围内。
Is converting Fixed Pt. (fixed n bit for fraction) to IEEE double safe ?
ie: does IEEE double format can represent all numbers a fixed point can represent ?
The test: a number goes to floating pt format then back to it's original fixed pt format.
Assuming your fixed point numbers are stored as 32-bit integers, yes, IEEE double precision can represent any value representable in fixed point. This is because double has a 53-bit mantissa, your fixed point values only have 32 bits of precision, and the floating-point exponent for the fixed point value is bounded between -32 and 32 (depending on where you consider the binary-point to lie in your fixed point values) which is well within the representable range.
这篇关于定点到浮点和向后的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!