Lua - packing IEEE754 single-precision floating-point numbers

╄→гoц情女王★ 提交于 2019-11-30 09:08:36

Multiply the significand you get from math.frexp() by 2^24, and subtract 24 from the exponent to compensate. Now the significand is an integer. Note that the significand is 24 bits, not 23 (you need to account for the implicit bit in the IEEE-754 encoding).

catwell

Have you seen this?

I think it does what you want in a slighty simpler way.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!