定点与浮点数 [英] Fixed point vs Floating point number

查看:111
本文介绍了定点与浮点数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于在Google上难以理解定点和浮点数的定义,因此我只是无法理解它们.但是,我所读的书中没有一个对它们的真实含义提供了足够简单的解释.我可以通过示例得到一个简单的定义吗?

I just can't understand fixed point and floating point numbers due to hard to read definitions about them all over Google. But none that I have read provide a simple enough explanation of what they really are. Can I get a plain definition with example?

推荐答案

定点数具有为整数部分(小数点左边的部分)保留的特定位数(或位数),并有一个特定的位数.保留给小数部分(小数点右边的部分)的位数.无论您的数字大小,它的每个部分将始终使用相同的位数.例如,如果定点格式为十进制IIIII.FFFFF,则可以表示的最大数字为99999.99999,最小的非零数字为00000.00001.处理此类数字的每一位代码都必须具有小数点在哪里的内置知识.

A fixed point number has a specific number of bits (or digits) reserved for the integer part (the part to the left of the decimal point) and a specific number of bits reserved for the fractional part (the part to the right of the decimal point). No matter how large or small your number is, it will always use the same number of bits for each portion. For example, if your fixed point format was in decimal IIIII.FFFFF then the largest number you could represent would be 99999.99999 and the smallest non-zero number would be 00000.00001. Every bit of code that processes such numbers has to have built-in knowledge of where the decimal point is.

浮点数没有为整数部分或小数部分保留特定位数.相反,它为该数字保留了一定数量的位(称为尾数 significand ),并在其中保留了一定数量的位来表示 where 小数点后的数字(称为指数).因此,一个占用10位数字并为指数保留2位数字的浮点数可能表示9.9999999e+50的最大值和0.0000001e-49的最小非零值.

A floating point number does not reserve a specific number of bits for the integer part or the fractional part. Instead it reserves a certain number of bits for the number (called the mantissa or significand) and a certain number of bits to say where within that number the decimal place sits (called the exponent). So a floating point number that took up 10 digits with 2 digits reserved for the exponent might represent a largest value of 9.9999999e+50 and a smallest non-zero value of 0.0000001e-49.

这篇关于定点与浮点数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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