为什么IEEE使用偏颇形式浮点数计算指数? [英] why IEEE floating point number calculate exponent using a biased form?

查看:160
本文介绍了为什么IEEE使用偏颇形式浮点数计算指数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

让我们说,为的浮动的类型在C中,根据IEEE浮点规范,也有使用8位为提交的分数,其计算公式为第一考虑这些8位和翻译成一个的无符号号,然后减去BIASE,这是2 ^ 7 - 1 = 127,其结果是一个指数范围是从-127至128以下。但是,为什么我们不能只把这些8位模式有符号数,因为生成的范围为[-128,127],这几乎是一样的previous之一。

let's say, for the float type in c, according to the IEEE floating point specification, there are 8-bit used for the fraction filed, and it is calculated as first taken these 8-bit and translated it into an unsigned number, and then minus the BIASE, which is 2^7 - 1 = 127, and the result is an exponent ranges from -127 to 128, inclusive. But why can't we just treat these 8-bit pattern as a signed number, since the resulting range is [-128,127], which is almost the same as the previous one.

推荐答案

偏置的目的是,使得指数存储在<青霉>无符号的形式,从而更容易做比较。从维基百科

The purpose of the bias is so that the exponent is stored in unsigned form, making it easier to do comparisons. From Wikipedia:

通过安排领域所以签收
  位在最显著位
  位置,在偏置指数
  中间,然后在最不尾数
  显著位,将所得的值
  将正常有序,无论是
  除preTED为浮点或
  整数值。这使得高速
  浮点数的比较
  使用固定点硬件。

By arranging the fields so the sign bit is in the most significant bit position, the biased exponent in the middle, then the mantissa in the least significant bits, the resulting value will ordered properly, whether it's interpreted as a floating point or integer value. This allows high speed comparisons of floating point numbers using fixed point hardware.

因此​​,基本上,一个浮点数是:

So basically, a floating point number is:

[sign] [unsigned exponent (aka exponent + bias)] [mantissa]

本网站提供关于为什么这是个好优秀的信息 - 特别,比较的实现浮点比较函数。

This website provides excellent information about why this is good - specifically, compare the implementations of floating point comparison functions.

此外,约浮点怪事没有完整的答案可以不提什么每台计算机科学家应该知道关于浮点运算。它的长,密,有点重的数学,但它的长期密集的数学金的(或类似的东西)。

Also, no complete answer about floating point oddities can go without mentioning "What Every Computer Scientist Should Know About Floating-Point Arithmetic." It's long, dense and a bit heavy on the math, but it's long dense mathematical gold (or something like that).

这篇关于为什么IEEE使用偏颇形式浮点数计算指数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆