当前位置:网站首页>Floating point notation (summarized from cs61c and CMU CSAPP)
Floating point notation (summarized from cs61c and CMU CSAPP)
2022-06-24 09:59:00 【Just a little advice】

Summarized from Berkeley's CS61C2021 Fall classes ,Nick Keynote speaker and CMU2015 Year talk CS APP Curriculum , The titles are floating point, Compared with CMU It was quite detailed , I read it first CS61C Read it again CMU Curriculum , Click on floating point Click on slides Can download pdf( It was very detailed. You can have a look at it for yourself , I selected a few to post ), course home https://inst.eecs.berkeley.edu/~cs61c/fa21/

P&H It's a textbook chapter , The Chinese version is a computer composition and design hardware and software interface RISCV

There is also a floating point number website that you can play https://www.h-schmidt.net/FloatConverter/IEEE754.html

The representation of floating point numbers was proposed by Berkeley , Because the decimal point can float , The accuracy is reduced but the representation range is enlarged (Can represent a very large range with roughly the same “precision”), And hope to be consistent with the complement representation of integers (32 individual 0 still 0), And I hope I can sort without comparing floating-point numbers (Make it possible to sort without needing to do floating-point comparisons)
float It's single precision 32 position 4 byte ,double yes 8 Byte double precision , Master first float,float What cannot be expressed is +∞, -∞, Not-A-Number (NaN), exponent overflow, exponent underflow, +/- zero So many special cases , What can be expressed is divided into normal format and denorm, The maximum can be expressed to 2 127 = 2 120 ∗ 2 7 = 128 ∗ ( 2 10 ) 12 = 128 ∗ 1 0 36 = 2 ∗ 1 0 38 2^{127}=2^{120}*2^7=128*(2^{10})^{12}=128*10^{36}=2*10^{38} 2127=2120∗27=128∗(210)12=128∗1036=2∗1038, according to 2 10 = 1 0 3 2^{10}=10^3 210=103 Convert to

Offset calculation method bias = 2 ^ (k - 1) - 1,k Is the number of exponential digits ,8 Bit index is calculated bias = 127( Positive and negative numbers stand half way ,bias gives us a balanced value), The decimal part can be expressed as fraction, F, mantissa, M, significand

Master first normal format, namely 1.xxx

denorm format Used to represent 0 Number of nearby ,0.xxx, The index part is 0000_0000, At this time, the decimal part does not need +1, Then the index part E = 1 - Bias( This part CMU Quite well , In order to achieve a smooth transition between the two representations , It can be used 8 Digit number , Index part k = 4 The offset is 7, The decimal part is 3 position ), The teacher commented those IEEE folks are really smart

overflow Part of the index is 1111_1111, First of all Inf And then there was NaN,NAN Usually sqer(-1) perhaps 0/0,NAN You can't compare sizes ,+INF yes 1.0/0.0,-INF yes -1.0/0.0,INF You can compare the size

Floating point numbers have +/- 0, A number that is too small to represent

To sum up

How to compare floating point numbers , Compare the sign bits first, then the exponents ( Unsigned comparison , Using offsets, you can directly compare sizes , If you use a complement, you can't directly compare sizes ), Finally, compare the decimal part ( The index part is important to distinguish the distribution of numbers , You can see on the number axis )

CMU In the course C The code can be written , See how to get NAN and INF Of , Direct definition a = 1e20,CMU The teacher did a good job in the course , these 0 and 1 It's not really a number , It's just that we see things from different angles ( Carelessness )
边栏推荐
- 顶刊TPAMI 2022!基于不同数据模态的行为识别:最新综述
- Getting user information for applet learning (getuserprofile and getUserInfo)
- TP5 using post to receive array data times variable type error: solution to array error
- How to make social media the driving force of cross-border e-commerce? This independent station tool cannot be missed!
- How does home office manage the data center network infrastructure?
- Oracle 12c升级至19c后ORA-28000错误
- Literature Research Report
- 桌面软件开发框架大赏
- LeetCode: 377. Combined sum IV
- Oracle database listening file configuration
猜你喜欢

使用Live Chat促進業務銷售的驚人技巧

Talking about the knowledge of digital transformation

411-栈和队列(20. 有效的括号、1047. 删除字符串中的所有相邻重复项、150. 逆波兰表达式求值、239. 滑动窗口最大值、347. 前 K 个高频元素)

ByteDance Interviewer: talk about the principle of audio and video synchronization. Can audio and video be absolutely synchronized?

Five heart matchmaker

SSH Remote Password free login

Grpc local test joint debugging tool bloomrpc

How to make social media the driving force of cross-border e-commerce? This independent station tool cannot be missed!

使用Live Chat促进业务销售的惊人技巧

R ellipse random point generation and drawing
随机推荐
文献调研报告
居家办公如何管理数据中心网络基础设施?
Ora-16038 ora-19502 ora-00312 troubleshooting
Oracle database listening file configuration
Mise en œuvre du rendu de liste et du rendu conditionnel pour l'apprentissage des applets Wechat.
Arbre binaire partie 1
有关二叉树 的基本操作
El table Click to add row style
LeetCode: 377. Combined sum IV
Detailed explanation of PHP singleton mode
el-table点击添加行样式
Amazing tips for using live chat to drive business sales
使用Live Chat促进业务销售的惊人技巧
Oracle viewing data file header SCN information
生产者/消费者模型
ByteDance Interviewer: talk about the principle of audio and video synchronization. Can audio and video be absolutely synchronized?
MYSQL数据高级
操作符详解
Five heart matchmaker
[Eureka registry]