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

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

问题描述

我只是无法理解定点数和浮点数,因为在 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.

浮点数不为整数部分或小数部分保留特定位数.相反,它为数字保留一定数量的位(称为 mantissasignificand)和一定数量的位来表示其中的 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天全站免登陆