underflow, overflow, approximation and rounding error

What is underflow and what is overflow?

In computer science, real numbers are represented in normalized floating-point representation. a floating-point representation consists of 2 parts: the mantissa and the exponent. Each part uses a particular number of bits. Due to the limitation of bits numbers, a fixed-number-of-bits representation has a range of numbers that can be represented. If a real number is too small, beyond the lower boundary of the range, it cannot be represented. This is underflow. If a real number is too large, beyond the upper boundary of the range, it cannot be represented either. This is overflow.

Why may a floating-point representation be an approximation?

Due to the limit of numbers of bits, a floating-point representation has a certain number of bits. some real numbers cannot be represented in binary form as exactly as in math. For example, -42.5, in binary form, it is
mantissa -> 10101011, 8 bits
exponent -> 0110, 4 bits
this form represents the value -42.5 exactly as in math.
but if 6 bits are used for mantissa, the last 2 bits 11 would be lost and it would be:
mantissa -> 101010, 6 bits
exponent -> 0110, 4 bits
but the new form represents the value -44, NOT -42.5. This happens because the limit of bits used to store the mantissa and exponent.
Another example is number 0.4. The ideal binary form is
0 0110 0110 0110 0110 0110 …
In a real computer system, we have to decide how many numbers of bits should be used to represent a number. We cannot use infinite number of bits for 0.4. The ideal binary form has to be truncated. This generates approximation too.

What is rounding error?

Rounding error/round-off error is the difference between the result produced by a given algorithm using exact arithmetic and the result produced by a finite-precision and rounded arithmetic.
Due to the fact that binary representation of a real number might be an approximation, computer algorithms might produce rounding errors.

Accuracy and Range

The number of bits used to represent a real number in floating-point representation affects the accuracy and range of numbers. The more bits for mantissa, the more accurate the number can be; the more bits for exponent, the wider range of numbers can be represented.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值