当前位置:网站首页>单精度,双精度和精度(转载)
单精度,双精度和精度(转载)
2022-06-22 05:34:00 【王建博09】
浮点数是计算机上最常用的数据类型之一,有些语言甚至数值只有浮点型(Perl,Lua同学别跑,说的就是你)。
常用的浮点数有双精度和单精度。除此之外,还有一种叫半精度的东东。
双精度64位,单精度32位,半精度自然是16位了。
半精度是英伟达在2002年搞出来的,双精度和单精度是为了计算,而半精度更多是为了降低数据传输和存储成本。
很多场景对于精度要求也没那么高,例如分布式深度学习里面,如果用半精度的话,比起单精度来可以节省一半传输成本。考虑到深度学习的模型可能会有几亿个参数,使用半精度传输还是非常有价值的。
Google的TensorFlow就是使用了16位的浮点数,不过他们用的不是英伟达提出的那个标准,而是直接把32位的浮点数小数部分截了。据说是为了less computation expensive。。。
比较下几种浮点数的layout:
双精度浮点数

单精度浮点数

半精度浮点数

它们都分成3部分,符号位,指数和尾数。不同精度只不过是指数位和尾数位的长度不一样。
解析一个浮点数就5条规则
如果指数位全零,尾数位是全零,那就表示0
如果指数位全零,尾数位是非零,就表示一个很小的数(subnormal),计算方式 (−1)^signbit × 2^−126 × 0.fractionbits
如果指数位全是1,尾数位是全零,表示正负无穷
如果指数位全是1,尾数位是非零,表示不是一个数NAN
剩下的计算方式为 (−1)^signbit × 2^(exponentbits−127) × 1.fractionbits
常用的语言几乎都不提供半精度的浮点数,这时候需要我们自己转化
原文地址:https://blog.csdn.net/sinat_24143931/article/details/78557852
边栏推荐
- Vulkan 预旋转处理设备方向
- 电脑卡顿怎么办?
- Someone always asks me: how to play independent station? Three cases, you will understand after reading
- Research Report on demand and investment opportunities in key areas of global and Chinese strontium tungstate industry 2022-2027
- nacos server 源码运行实现
- Hide symbol of dynamic library
- Go language uses JWT
- [issue 26] 123hr experience of Tencent teg+ operation development
- Development prospect forecast and investment strategy analysis report of global and Chinese manganese oxide nano powder industry 2022-2028
- SCM future employment development direction, learn SCM must know some entry-level knowledge and industry prospects, read the benefit
猜你喜欢

Error: note: module requires go 1.17

Data storage (Advanced)

RGB及sRGB与XYZ坐标转换

AUTOSAR从入门到精通100讲(150)-SOA架构及应用

U disk as startup disk to reinstall win10 system (no other software required)

机器学习笔记 六:逻辑回归中的多分类问题之数字识别

Xshell download and installation (solve the problem of expired evaluation)

Conversion between gray code and binary

Sourcetree reported an error SSH failure

Network, IO flow, reflection, multithreading, exception
随机推荐
Dos Bat 语法记录一
给仍在「 选品 」的跨境卖家提个醒!
Analysis on the development status of China's copper aluminum composite bus industry and Research Report on investment opportunities 2022-2027
QEMU ARM interrupt system architecture
非传递骰子(春季每日一题 51)
MATLAB系统辨识
Redis connection error: err client send auth, but no password is set 2 solutions
Which is the trend of cross-border policy frequent adjustment of "independent stations & platforms"?
SCM future employment development direction, learn SCM must know some entry-level knowledge and industry prospects, read the benefit
使用Systemverilog描述状态机
Error: note: module requires go 1.17
JTAG接口
CMAKE notes
信号输出库
C指針的理解
nacos server 源码运行实现
Stockage des données (avancé)
北峰助力南昌市应急管理局打造公专融合应急通信保障网
数据的存储(进阶)
n个整数的无序数组,找到每个元素后面比它大的第一个数,要求时间复杂度为O(N)