当前位置:网站首页>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 )
边栏推荐
- js代理模式
- 《MATLAB 神经网络43个案例分析》:第32章 小波神经网络的时间序列预测——短时交通流量预测
- Algorithm -- find and maximum length k subsequence (kotlin)
- Detailed explanation of ThinkPHP 5.0 Model Association
- Amazing tips for using live chat to drive business sales
- JS singleton mode
- Oracle数据库监听文件配置
- Getting user information for applet learning (getuserprofile and getUserInfo)
- Oracle数据库EXPDP只导出表的方法
- Analysis of 43 cases of MATLAB neural network: Chapter 32 time series prediction of wavelet neural network - short-term traffic flow prediction
猜你喜欢

顶刊TPAMI 2022!基于不同数据模态的行为识别:最新综述

Amazing tips for using live chat to drive business sales

物联网?快来看 Arduino 上云啦

Five heart matchmaker

如何管理海量的网络基础设施?

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

Idea cannot save settings source root d:xxxx is duplicated in module XXX

记录一下MySql update会锁定哪些范围的数据

《MATLAB 神经网络43个案例分析》:第32章 小波神经网络的时间序列预测——短时交通流量预测

操作符详解
随机推荐
如何规范化数据中心基础设施管理流程
Nvisual digital infrastructure operation management software platform
Ora-16038 ora-19502 ora-00312 troubleshooting
Five heart matchmaker
IDEA 无法保存设置 源根 D:XXXX在模块XXX中重复
编程题(持续更新)
记录一下MySql update会锁定哪些范围的数据
Thinkphp5 clear the cache cache, temp cache and log cache under runtime
Can the long-term financial products you buy be shortened?
Queue queue
El table Click to add row style
Operator details
Implementation of simple floating frame in WindowManager
grpc本地测试联调工具BloomRPC
Get the QR code of wechat applet with parameters - and share the source code of modifying the QR code logo
5分钟,客服聊天处理技巧,炉火纯青
How to manage massive network infrastructure?
canvas 绘制图片
How to locate lock waiting in Dameng database
PostgreSQL DBA快速入门-通过源码编译安装