Float

Chris Angelico rosuav at gmail.com
Sat Jul 30 07:51:29 EDT 2016


On Sat, Jul 30, 2016 at 9:44 PM, Cai Gengyang <gengyangcai at gmail.com> wrote:
> You mentioned that : A floating point number[2] is number that is not an integer (and not a
> complex number)
>
> Hence ,
>
> 10 is not a floating point number because it is an integer
> 25 is not a floating point number because it is an integer
> 7 + 3i is not a floating number because it is a complex number
> 8 + 5i is not a floating number because it is a complex number.
>
> Is 3.0 a floating number ? It is a rational number, not an integer right ?

In a computing context, data types are incredibly significant. So yes,
3.0 *is* a floating-point number. It's equal to the integer 3, because
they represent the same number, but it's not identical to it. You can
convert from one to the other with the built-ins int and float:

>>> 3.0 == 3
True
>>> int(3.0)
3
>>> float(3)
3.0

ChrisA



More information about the Python-list mailing list