在python中 float是什么意思?

我就想知道什么是float

float是一种数据类型。

浮点型数据类型,FLOAT 数据类型用于存储单精度浮点数或双精度浮点数。浮点数使用 IEEE(电气和电子工程师协会)格式。浮点类型的单精度值具有 4 个字节,包括一个符号位、一个 8 位 二进制指数和一个 23 位尾数。

由于尾数的高顺序位始终为 1,因此它不是以数字形式存储的。此表示形式为 float 类型提供了一个大约在 -3.4E+38 ~ 3.4E+38 之间的范围。


扩展资料:

相关用法

存储为二进制分数的尾数大于或等于 1 且小于 2。对于 float 和 double 类型,最高有效位位置的尾数中有一个隐含的前导 1,这样,尾数实际上分别为 24 和 53 位长,即使最高有效位从未存储在内存中也是如此。

浮点包可以将二进制浮点数存储为非标准化数,而不使用刚刚介绍的存储方法。“非标准化数”是带有保留指数值的非零浮点数,其中尾数的最高有效位为 0。

通过使用非标准化格式,浮点数的范围可以扩展,但会失去精度。您无法控制浮点数以标准化形式还是非标准化形式表示;浮点包决定了表示形式。

用法举例

如果存储比精度更重要,请考虑对浮点变量使用 float 类型。相反,如果精度是最重要的条件,则使用 double 类型。

浮点变量可以提升为更大基数的类型(从 float 类型到 double 类型)。当您对浮点变量执行算术时,通常会出现提升。此算术始终以与具有最高精度的变量一样高的精度执行。例如,请考虑下列类型声明:

float f_short;double f_long;long double f_longer;f_short = f_short * f_long;

在前面的示例中,变量f_short提升到类型 double 并且与f_long相乘;然后,结果舍入到类型 float,然后赋给f_short。

参考资料来源:百度百科-FLOAT



温馨提示:答案为网友推荐,仅供参考
第1个回答  推荐于2017-09-25
  浮点型(Float)

  Python的浮点数就是数学中的小数,类似C语言中的double。

  在运算中,整数与浮点数运算的结果是浮点数.

  浮点数也就是小数,之所以称为浮点数,是因为按照科学记数法表示时,一个浮点数的小数点位置是可变的,比如,1.23x109和12.3x108是相等的。浮点数可以用数学写法,如1.23,3.14,-9.01,等等。但是对于很大或很小的浮点数,就必须用科学计数法表示,把10用e替代,1.23x109就是1.23e9,或者12.3e8,0.000012可以写成1.2e-5,等等。

  整数和浮点数在计算机内部存储的方式是不同的,整数运算永远是精确的而浮点数运算则可能会有四舍五入的误差。
第2个回答  2009-08-02
float 就是浮点数,看python的manual
float( [x])

Convert a string or a number to floating point. If the argument is a string, it must contain a possibly signed decimal or floating point number, possibly embedded in whitespace. Otherwise, the argument may be a plain or long integer or a floating point number, and a floating point number with the same value (within Python's floating point precision) is returned. If no argument is given, returns 0.0.
Note: When passing in a string, values for NaN and Infinity may be returned, depending on the underlying C library. The specific set of strings accepted which cause these values to be returned depends entirely on the C library and is known to vary.
第3个回答  2009-08-01
float型数据,浮点型

详细介绍看这里
http://docs.python.org/tutorial/floatingpoint.html
第4个回答  2009-08-01
浮点类型变量
也就是小数的意思
相似回答