当前位置:网站首页>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 .
边栏推荐
- [7.13] code source - [hungry meals] [path count 2] [function sum]
- onvif协议相关:3.1.2 Digest方式获取token列表
- onvif協議相關:4.1.3 WS-Username token方式獲取截圖url
- 忘掉Postman,Apifox更好用
- Start from here by counting the information of the broadcast room
- Onvif protocol related: 3.1.3 get screenshot URL in digest mode
- onvif协议相关:2.1.3 none方式获取流地址
- 【7.12】Codeforces Round #806 (Div. 4)
- 2. Sum of three numbers
- onvif协议相关:4.1.3 WS-Username token方式获取截图url
猜你喜欢
No.3汇编进阶
【考研词汇训练营】Day 5 —— alarmist,cooperate,point,benefit,industrial,revolution,mechanize
2. Sum of three numbers
How to upgrade Flink job gracefully?
Onvif protocol related: 4.1.4 WS username token method to obtain the stream address
Flutter uses animatedswitcher to switch scenes
Programming examples of stm32f1 and stm32subeide -mpu-6050 six axis (gyroscope + accelerometer) drive
onvif协议相关:4.1.1 WS-Username token方式获取WSUsernameTokenBean
Onvif protocol related: 3.1.1 digest access authorization
Google Earth engine - 1992 present mixed coordinate ocean model, water temperature and salinity (global ocean data set HYCOM)
随机推荐
弘业期货网上开户安全吗?有没有开户指引?
OpenSSL操作
大家好,问一下数据库没开始binlog如何实时同步么,有没有好的方案
【南瓜书ML】(task2)线性模型的数学推导(最小二乘估计、广义瑞利商、极大似然估计等)
Some common operation commands of the command line and solutions to common errors
Health prevention guide 3: health care
chrome插件用于信息收集
关于数据字典的一些解惑
Flutter 使用 AnimatedSwitcher 做场景切换
【7.8】Educational Codeforces Round 131 (Rated for Div. 2)
Template virtual machine environment preparation
【码蹄集新手村 600 题】格式化的输入输出,使用 0 来代替补全的空格
S32K148_ Can drive (bare metal development)
NO.4位、字节、信息存储
"Podcast with relish" 392 original soup, original food: midsummer night, mashed horse, kebab, and pull board
Android开发大厂面试,做好这3个准备,规划好自己
Onvif protocol related: 4.1.1 WS username token method to obtain wsusernametokenbean
【码蹄集新手村 600 题】科学计数法的实现方式,输出指数形式
【7.14】代码源 -【拆方块】【XOR Inverse】【连续子序列】【三角果计数】
NO.5整数的表示与运算