当前位置:网站首页>Four rounding modes in IEEE754 standard
Four rounding modes in IEEE754 standard
2022-06-11 22:37:00 【luoganttcc】
One 、 Preface
Recently, I was writing a project based on IEEE754 standard Of floating-point adder , One of the requirements is to meet IEEE754 standard Four rounding modes of .
When we normalize order or right , The operands with smaller order are shifted to the right , It will cause the lower bits of the mantissa to be lost , This will cause errors . That's why we need to meet our needs , One of the four rounding modes is used to round the mantissa to reduce the error .
Two 、IEEE754 Standard 4 Rounding mode
1、 Nearest rounding :
Namely ten Base number Under the rounding . But there are also the following situations :
- The extra number is 1001, It is greater than 0.5, Therefore, the lowest position goes into 1.
- The extra number is 0111, It's smaller than 0.5, Then discard the extra numbers directly .
- The extra number is 1000, Is exactly equal to 0.5 In special circumstances ; Then the lowest order is 0 Then we give up the extra places , The lowest is 1 Then carry 1.
Note that the digits here are binary numbers . Because this is the mantissa , So we are calculating these binary sums 0.5 In a relationship , That is to say 10 When in base , We multiply the weight of each bit by 2^(-i) Then sum up .
2、 the 0 Round off : That is, round to the zero point of the number axis , So let's just cut the tail .
3、 Round to infinity : For positive numbers , All the extra bits are 0 Then cut the tail directly , Not all for 0 Then carry... To the least significant bit 1; Negative numbers, no matter how many extra bits, can be truncated directly .
4、 Round to negative infinity : For negative numbers , All the extra bits are 0 Then cut the tail directly , Not all for 0 Then carry... To the least significant bit 1; If it is a positive number, you can truncate it directly regardless of the number of extra bits .
3、 ... and 、 give an example
After the decimal point is required 3 position
1、 Nearest rounding :
about 1.001_1001, After rounding, it is 1.010( Get rid of the excess 4 position , Add 0.001)
about 1.001_0111, After rounding, it is 1.001( Get rid of the excess 4 position )
about -1.001_1000, After rounding, it is -1.010( Get rid of the excess 4 position , Add 0.001, Because the lowest order is 1)
about -1.010_1000, After rounding, it is -1.010( Just get rid of the excess 4 position , Because the lowest order is 0)
2、 the 0 Round off :
// Positive numbers are truncated directly
about 1.001_1001, After rounding, it is 1.001( Just get rid of the excess 4 position )
about 1.001_0111, After rounding, it is 1.001( Just get rid of the excess 4 position )
// Negative numbers are truncated directly
about -1.001_1000, After rounding, it is -1.001( Just get rid of the excess 4 position )
about -1.010_1000, After rounding, it is -1.010( Just get rid of the excess 4 position )
3、 Round to infinity :
// The extra bits of a positive number are not all 0 carry 1
about 1.001_1001, After rounding, it is 1.010( Get rid of the excess 4 position , Add 0.001)
about 1.001_0111, After rounding, it is 1.010( Get rid of the excess 4 position , Add 0.001)
// All the extra bits of a positive number are 0 Straight tailing
about 1.001_0000, After rounding, it is 1.001( Just get rid of the excess 4 position )
// Negative numbers are truncated directly
about -1.001_1010, After rounding, it is -1.001( Just get rid of the excess 4 position )
4、 Round to negative infinity :
// Positive numbers are truncated directly
about 1.001_1001, After rounding, it is 1.001( Just get rid of the excess 4 position )
about 1.001_0111, After rounding, it is 1.001( Just get rid of the excess 4 position )
// All the extra bits of negative numbers are 0 Straight tailing
about -1.001_0000, After rounding, it is -1.001( Just get rid of the excess 4 position )
// The extra bits of negative numbers are not all 0 carry 1
about -1.001_1010, After rounding, it is -1.010( Get rid of the excess 4 position , Add 0.001)
边栏推荐
- The device is in use when win10 ejects USB
- 阿里云服务器mysql远程连接一直连不上
- Getting started with message queuing MQ
- Matlab point cloud processing (XXIV): point cloud median filtering (pcmedian)
- Stack栈的实现
- [Yu Yue education] General English of Shenyang Institute of Engineering (4) reference materials
- 3.3 naming rules of test modules
- Simple example of logistic regression for machine learning
- Unity3D getLaunchIntentForPackage 获取包返回null问题
- 【数据挖掘时间序列分析】餐厅销量预测
猜你喜欢

二叉树的基本操作与题型总结
![[solution] solution to asymmetric and abnormal transformation caused by modifying the transform information of sub objects](/img/52/7e741154e4d6e61c5df7e8701ab177.png)
[solution] solution to asymmetric and abnormal transformation caused by modifying the transform information of sub objects

Basic operation and question type summary of binary tree

How to view computer graphics card information in win11

Study notes of mattlotlib and Tkinter (I)

Explain asynchronous tasks in detail: the task of function calculation triggers de duplication

Tkinter study notes (IV)

0-1 knapsack problem of dynamic programming (detailed explanation + analysis + original code)

Basic operation of graph (C language)

astra pro双目相机ros下启动笔记
随机推荐
SecurityContextHolder.getContext().getAuthentication().getPrincipal()获取到的是username而不是UserDetails
完好性简要介绍
volatile的解构| 社区征文
[Chongqing Guangdong education] college physics of Xiangtan University: mechanical and thermal reference materials
【解决】修改子物体Transform信息导致变换不对称、异常问题的解决方案
SequenceList顺序表的实现
16 | 浮点数和定点数(下):深入理解浮点数到底有什么用?
PHP+MYSQL图书管理系统(课设)
Exercise 8-8 moving letters (10 points)
习题9-6 按等级统计学生成绩 (20 分)
Svn deploys servers and cleints locally and uses alicloud disks for automatic backup
2022新兴市场品牌出海线上峰会即将举办 ADVANCE.AI CEO寿栋将受邀出席
Basic operation and question type summary of binary tree
Matlab point cloud processing (XXIV): point cloud median filtering (pcmedian)
启牛推荐开通的证券账户安全吗?靠谱吗
926. 将字符串翻转到单调递增
Tkinter学习笔记(三)
[uniapp native plug-in] shangmi cashbox plug-in
360 online enterprise security cloud is open to small, medium and micro enterprises for free
Exercise 11-2 find week (15 points)