Float

Steven D'Aprano steve at pearwood.info
Sat Jul 30 06:34:12 EDT 2016


On Sat, 30 Jul 2016 08:21 pm, Cai Gengyang wrote:

> Cool ... can you give a concrete example ?

A concrete example of a float?

I already gave two:


>> Python floats use 64 bits (approximately 18 decimal digits). Because the
>> decimal point can "float" from place to place, they can represent very
>> small numbers:
>> 
>> 1.2345678901234567e-100
>> 
>> and very big numbers:
>> 
>> 1.2345678901234567e100


Here are some more:

0.5  # one half
0.25  # one quarter
7.5  # seven and a quarter
0.001  # one thousandth

12345.6789
# twelve thousand, three hundred and forty-five, point six seven eight nine

-1.75  # minus one point seven five
0.0  # zero
3.0  # three

1.23e45  # one point two three times ten to the power of forty-five




-- 
Steven
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.




More information about the Python-list mailing list