博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Converting between IEEE 754 and Float (Format related
阅读量:6386 次
发布时间:2019-06-23

本文共 1504 字,大约阅读时间需要 5 分钟。

The float can be converted to well known single-precision IEEE 754 number, why 754? It's the standard representation of single-precision numbers, used in net transmission.

Compares to send the float as text or send/receive without re-formatting/un-formatting, it's much faster & safer. 

What confuses me is that nowadays floats are stored just what IEEE 754 says to be. Or maybe windows only?

But the most important thing is, when sending/receiving data/numbers, use standards.

See for more info.

I'll explain this format a little. It uses the first bit as a sign representation(1 if negative), the following 8bit as its exponential part, the last 23bit as its fraction part.

See this example:

1 10000001 10110011001100110011010

sign   expo       mantissa

It is divided as stated above.

The Microsoft's floats is following this standard. See the following definition of float in Windows. 

Where float uses 8 bits of exponent and 23 bits of mantissa, compares to double's 11 bits of exponent and 52 bits of mantissa.

About the bias refered to in the page above:

Because exponents are stored in an unsigned form, the exponent is biased by half its possible value.For type float, the bias is 127; for type double, it is 1023.You can compute the actual exponent value by subtracting the bias value from the exponent value.

/QUOTE

Note that this exponent's base is not 10, of course it's 2! So 2E127 is approximately 10E38, that's why float's range is about 1E-38~3E38!

转载于:https://www.cnblogs.com/sansna/p/5421648.html

你可能感兴趣的文章
thinkphp 多语言
查看>>
JS 表单自动提交
查看>>
poj1005
查看>>
输入输出流
查看>>
java接口,避开登录方法-
查看>>
DFS/BFS(同余模) POJ 1426 Find The Multiple
查看>>
Codeforces Round #343 (Div. 2)
查看>>
解决 Eclipse 导入项目后 Maven Dependencies missing jar 问题
查看>>
23. Node.Js Buffer类(缓冲区)-(三)文件读取实例
查看>>
29.OGNL与ValueStack(VS)-总结OGNL[重点]
查看>>
JSTL之C标签的用法
查看>>
泛型类型参数及约束
查看>>
Docker学习笔记整理
查看>>
struts2语法--error页面如何捕获?
查看>>
C++:ostringstream如何清空
查看>>
第二个spring, 第7天
查看>>
zabbix的邮件报警
查看>>
如何通过无线网卡共享宽带有线连接
查看>>
JS部分基础知识点
查看>>
winform 制作圆形图片框
查看>>