Note_20150306_Computer Arithmetic_Number Representation

本文探讨了计算机科学中时间计算的精确性问题及其与数学原理的关系,特别关注十进制时间计算的误差来源。同时,文章深入分析了补码表示在数字系统中的应用,包括其优点、缺点以及在不同场景下的使用方式。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Mathematics, like the Nile, begins in munuteness, but ends in magnificence。


The first such event, which may have led to the loss of 28 human lives in February 1991, is the failure of the American Patriot missile battery in Dhahran, Saudi Arabia, to intercept a number of Iraqi Scud missiles. An investigation by the US general Accounting office blamed the incident on a software problem that led to in accurate calculation of elapsed time since the last system boot. It was explained that the system's internal clock measured time in tenths of a second. The measured time was then multiplied by a 24-bit trancated fractional representation of 1/10, with an erro of about (3/4)x10(-23) = 10(-7). Some error was unavoidable, because 1/10 does not have an exact binary representation.









Advantages of signed-magnitude representation include its intuitive appeal, conceptual simplicity, symmetric range, and simple negation by flipping or inverting the sign bit. The primary disadvantage is that addition of numbers with unlike signs (subtraction) must be hadled differently from that of same-sign operands.

Biased representation does not lend itself to simple arithmetic algorithms. Addition and subtraction become somewhat more complicated because one must subtract or add the bias from/to the reult of a normal add/subtract operation, since

x + y + bias = (x + bias) + (y + bias) - bias

x - y + bias = (x + bias)  - (y + bias) + bias

For this reason, the practical use of biased representation is limited to the exponent parts of floating-point numbers, which are never multiplied or divided.


In the special case of r =2, the radix complement representation that corresponds to M=2^k is known as 2's complement.

The digit or diminished-radix complement representation is known as 1's complement in the special case of r =2.


In the complement system with the complementation constant M and the number representation range [-N, +P], addition is done by adding the respective unsigned representations (modulo M). Assuming that a selective complementer is available, addition and subtraction become essentially the same operation, and this the primary advantage of complement representations.

Two choices allow just this for fixed-point redix-r arithmetic with k whole digits and l fractional digits:

Radix complement      M = r^k;

Digit or diminished-radix complement M = r^k - ulp;












评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值