Converting between IEEE 754 and Float (Format related
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, wh
2024-10-30 15:41:53 原文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 this page 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!
Converting between IEEE 754 and Float (Format related的更多相关文章
- IEEE 754标准
IEEE 754-1985 was an industry standard for representing floating-point numbers in computers, officia ...
- IEEE二进制浮点数算术标准(IEEE 754)
整理自IEEE 754 IEEE二进制浮点数算术标准(IEEE 754)是20世纪80年代以来最广泛使用的浮点数运算标准,为许多CPU与浮点运算器所采用.这个标准定义了表示浮点数的格式(包括负零-0) ...
- 浮点数在计算机内存中的表示(IEEE 754规定1位是符号位,8位是指数,剩下的23位为有效数字)
本文转载自:阮一峰的博客,http://www.ruanyifeng.com/blog/2010/06/ieee_floating-point_representation.html 张玉彬的博客 h ...
- 【算法】解析IEEE 754 标准
目录结构: contents structure [-] 浮点数的存储过程 次正规数(Denormalized Number) 零(zero) 非数值(NaN) 无穷大(infinity) 除数为0. ...
- 【转】浮点数与IEEE 754
http://www.cnblogs.com/kingwolfofsky/archive/2011/07/21/2112299.html 浮点数 1. 什么是浮点数 在计算机系统的发展过程中,曾经 ...
- IEEE 754浮点数表示标准
二进制数的科学计数法 C++中使用的浮点数包括采用的是IEEE标准下的浮点数表示方法.我们知道在数学中可以将任何十进制的数写成以10为底的科学计数法的形式,如下 其中显而易见,因为如果a比10大或者比 ...
- IEEE 754 浮点数在计算机中的表示方法
IEEE二进制浮点数算术标准(IEEE 754)是20世纪80年代以来最广泛使用的浮点数运算标准,为许多CPU与浮点运算器所采用.这个标准定义了表示浮点数的格式(包括负零-0)与反常值(denorma ...
- 基于 IEEE 754 标准的 单精度浮点数计算方式 (未完成)
def dec2bin(dec): if dec < 0: s = ' dec = dec * (-1) else: s = ' e = 127 dec = float(dec) r = int ...
- 打印一个浮点数组,会输出字符串"Hello, world“ & 浮点数的二进制表示(IEEE 754标准)
#include <stdio.h> #include<stdlib.h> int main() { float a[3] = { 1143139122437582505939 ...
随机推荐
- 自定义MVC框架(一)-(没有基于xml的)
0.创建oracle的sql语句如下 --创建表 create table userinfo(id number primary key,uname varchar2(20),password var ...
- LeetCode OJ 53. Maximum Subarray
Find the contiguous subarray within an array (containing at least one number) which has the largest ...
- TortoiseGit - 分支管理 -增加分支
1.本地当前在master分支,右击选择Create Branch... 2.填写Branch的名称 3.右击选择Push,在Ref-Local,选择刚才新建的Branch名称 4.点击OK后,在弹出 ...
- Openjudge-计算概论(A)-统计字符数
描述: 判断一个由a-z这26个字符组成的字符串中哪个字符出现的次数最多输入第1行是测试数据的组数n,每组测试数据占1行,是一个由a-z这26个字符组成的字符串每组测试数据之间有一个空行,每行数据不超 ...
- Openjudge-计算概论(A)-奇数单增序列
描述: 给定一个长度为N(不大于500)的正整数序列,请将其中的所有奇数取出,并按升序输出. 输入共2行:第1行为 N:第2行为 N 个正整数,其间用空格间隔.输出增序输出的奇数序列,数据之间以逗号间 ...
- erlang ets表
一.表遍历 通过ets:first/1获取表的第一个关键字,表中下一个关键字用ets:next/2得到,直到ets:next/2返回'$end_of_table' 当多几个进程并发访问ets表时,可以 ...
- 2.按要求编写Java应用程序: (1)编写西游记人物类(XiYouJiRenWu) 其中属性有:身高(height),名字(name),武器(weapon) 方法有:显示名字(printName),显示武器(printWeapon) (2)在主类的main方法中创建二个对象:zhuBaJie,sunWuKong。并分别为他 们的两个属性(name,weapon)赋值,最后分别调用printNam
XiYouJiRenWu package com.hanqi.test; public class XiYouJiRenWu { String height,name,weapon; XiYouJiR ...
- UVALive 7077 Little Zu Chongzhi's Triangles (有序序列和三角形的关系)
这个题--我上来就给读错了,我以为最后是一个三角形,一条边可以由多个小棒组成,所以想到了状态压缩各种各样的东西,最后成功了--结果发现样例过不了,三条黑线就在我的脑袋上挂着,改正了以后我发现N非常小, ...
- STM32 一通道单次转换
之前弄过ADC连续转换,还配了DMA传输,项目上不希望这样做,因为有其他设备用到DMA传输,就会不停的抢占优先级,效率低. 按照需求改成ADC单次转换,非连续,用的时候只需调下函数执行一次转换即可. ...
- hdu_5742_It's All In The Mind
题目链接:hdu_5742_It's All In The Mind 题意: 有一个部分的数列,让你找一个满足他给的三个条件的数列,使前两个数的和除这个数列的sum最大 题解: xjb贪心一下就行了. ...