Significant digits in a float?

Ben Finney ben at benfinney.id.au
Mon Apr 28 23:23:07 EDT 2014


Steven D'Aprano <steve+comp.lang.python at pearwood.info> writes:

> By the way, you contradict yourself here. Earlier, you described 38.0 as 
> having zero decimal places (which is wrong). Here you describe it as 
> having one, which is correct, and then in a later post you describe it as 
> having zero decimal places again.

I get the impression that this is at the core of the misunderstanding.
Having a number's representation ending in “….0” does not mean zero
decimal places; it has exactly one. The value's representation contains
the digit “0” after the decimal point, but that digit is significant to
the precision of the representation.

If the problem could be stated such that “38.0” and “38” and “38.000”
are consistently described with the correct number of decimal digits of
precision (in those examples: one, zero, and three), maybe the
discussion would make more sense.

-- 
 \     “Men never do evil so completely and cheerfully as when they do |
  `\        it from religious conviction.” —Blaise Pascal (1623–1662), |
_o__)                                                   Pensées, #894. |
Ben Finney




More information about the Python-list mailing list