当前位置:网站首页>No.6 representation and operation of floating point numbers
No.6 representation and operation of floating point numbers
2022-07-19 13:45:00 【L.Bubu】
Catalog
1.IEEE Floating point standard
1.5 Normalized value is the first positive integer that cannot be accurately expressed
2.1 Rounding mode : Round to even
1.IEEE Floating point standard
1.1 Basic concepts
●IEEE 754 standard :
On 1985 establish , Before, every computer manufacturer designed its own rules , Support all mainstream CPU
● For the accuracy of numerical operation :
Support rounding , Overflow and other operations , Defined on a small and consistent set of rules —— Quite elegant , Easy to understand .
● Mathematical form :
(-1)^s * M * 2^E

s: Sign bit .
M: mantissa , It's a binary decimal , The scope is [1.0, 2.0).
E: Order code , Express 2 The power of .
1.2 Normalized value
● Judge the condition : exp ≠ 000…0 and exp ≠ 111…1
● The level code field is interpreted as offset ( biased) A signed integer in the form of : E = Exp – Bias
●Exp: An unsigned number exp
●Bias = 2^(k-1) - 1, among k Is the order code number
● mantissa : M = 1.xxx…x(2 Base number )
xxx…x: frac The bit of "s" means
minimum value 000…0 (M = 1.0)
Maximum :111…1 (M = 2.0 – 0.0…01)
1.3 Denormalization value
● Judge the condition : exp = 000…0
● Order code value : E = –Bias + 1 ( Notice that it's not E = 0 – Bias)
● mantissa : M = 0.xxx…x2
●xxx…x: frac value
● Example
exp = 000…0, frac = 000…0(+0 And -0 There are differences )
exp = 000…0, frac ≠ 000…0
1.4 Special values
● Judge the condition : exp = 111…1
● example : exp = 111…1, frac = 000…0
Express ∞ ( infinite ),s=1 Negative time is infinite ,s=0 Timing is infinite
Can express the result of overflow
E.g., 1.0/0.0 = −1.0/−0.0 = +∞, 1.0/−0.0 = −∞
● example : exp = 111…1, frac ≠ 000…0
It's not a number (NaN)
Some unspeakable numbers
E.g., sqrt(–1), ∞ − ∞, ∞ * 0
1.5 Normalized value is the first positive integer that cannot be accurately expressed
IEEE Able to express float The growth of the number is shown in the figure :


Set order code yes M position , Mantissa has N position :
When (2^M-1-Bias) < (N+1) when , Integers in the range can be accurately expressed ;
When (2^M-1-Bias) = (N+1) when , The first integer that cannot be accurately expressed is 2^(N+1)+1.
2. Rounding and operation
2.1 Rounding mode : Round to even
Operation idea : First calculate the exact result , Then get the approximate result by rounding .
2.2 Multiplication
{(-1)^s1 * M1 * 2^E1} * {(-1)^s2 * M2 * 2^E2}
● Precise results :(-1)^s * M * 2^E
▲s = s1 + s2
▲M = M1 * M2
▲E = E1 + E2
● adjustment
▲ If M ≥ 2, M Moves to the right one , E=E+1
▲ If E Out of range , overflow .
▲ take M Round to frac Range of digits .
2.3 Addition operation
1) Antithetic order : Small steps to large ones
When the order codes of two numbers are the same , Indicates that the positions of the decimal points of two numbers are aligned , At this point, you can add . Before adding , It is necessary to align the order , Small steps align with large ones . The order code of small order plus K Equal to the order code of large order , At the same time, the mantissa of the small order should be shifted to the right K position .
2) Add mantissa .
3) Normalize the result and round .
4) Judge whether it overflows according to the order code .
边栏推荐
- [JS reverse crawler] - Youdao translation JS reverse practice
- 【6.15】Codeforces Round #798 (Div. 2)
- 国内外十大erp软件系统排名!
- 大家好,问一下数据库没开始binlog如何实时同步么,有没有好的方案
- NO.5整数的表示与运算
- Onvif protocol related: 2.1.1 get token in none mode
- 565. Array nesting
- 「津津樂道播客」#392 原湯話原食:仲夏夜,馬砂、肉串兒、趿拉板兒
- STL string复制比较
- Codeforce:g. good key, bad key [greed]
猜你喜欢

Onvif protocol related: 2.1.1 get token in none mode

【码蹄集新手村 600 题】科学计数法的实现方式,输出指数形式

onvif协议相关:3.1.4 Digest方式获取流地址
![[code hoof set novice village 600 question] calculate the number of digits of an integer](/img/4b/4c2b6889decd30bb2e0f3b28dee0cf.png)
[code hoof set novice village 600 question] calculate the number of digits of an integer

Onvif protocol related: 3.1.3 get screenshot URL in digest mode

2. Sum of three numbers

Google Earth engine - 1992 present mixed coordinate ocean model, water temperature and salinity (global ocean data set HYCOM)

Weekly summary (*65): planned output

ModuleNotFoundError: No module named ‘_distutils_hack‘

Flutter 使用 AnimatedSwitcher 做场景切换
随机推荐
How to add a thread in MFC
Interviewer: is it acceptable to transfer to go?
"Podcast with relish" 392 original soup, original food: midsummer night, mashed horse, kebab, and pull board
codeforce:G. Good Key, Bad Key【贪心】
[micro Service ~ advanced] configuration center practice
AcWing 136. 邻值查找
语音通信网络的原理
STM32F1与STM32CubeIDE编程实例-MPU-6050 六轴(陀螺仪 + 加速度计)驱动
[code hoof set novice village 600 questions] the implementation of scientific counting method, output index form
Transphorm的表面贴装封装产品系列增加行业标准TO-263 (D2PAK)封装产品,扩大SuperGaN平台的优势
命令行的一些常用操作命令及常见错误的解决办法
【7.15】代码源 -【整齐的数组2】【三进制循环】【树上逆序对】【蜗蜗的数列】
Galaxy Kirin V10 arm offline installation of portal
【7.13】代码源 -【饿饿 饭饭】【路径计数2】【函数求和】
Code after annotation of hands-on deep learning (Second Edition) [continuous update]
onvif协议相关:3.1.1 Digest方式获取Authorization
Principle of voice communication network
弹性负载均衡将访问流量自动分发到多台云服务器,扩展应用系统对外的服务能力,提高应用程序安全性。
【码蹄集新手村 600 题】如何使整数逆序
NO.5整数的表示与运算