[Python-ideas] Way to check for floating point "closeness"?

Ethan Furman ethan at stoneleaf.us
Wed Jan 14 21:38:29 CET 2015


On 01/14/2015 12:04 PM, Ron Adam wrote:
> On 01/14/2015 10:44 AM, Chris Barker wrote:
>> On Wed, Jan 14, 2015 at 1:08 AM, Ron Adam wrote:
>>
>>> Significant digits has more to do with error of measurements, (and
>>> estimates),
>>
>> right -- and relative tolerance is kinda-sorta like significant digits. i.e
>> a relative tolerance of 1e-4 is like saying the same to 4 (decimal)
>> significant digits.
>>
>> which brings up the issue with 0.0 -- how many significant digits does 0.0
>> have?
> 
> It has as many significant places as your data is measured or estimated to.  If your data is entered with four places,
> then 0.0 is actually 0.0000. And a value displayed as 1.1 that was entered as 1.1000 would still have 4 significant places.
> 
>> does 0.000001234 have the same significant digits as 0.0 ?  -- its not
>> really defined.
> 
> Well, if the significant digits/places was 4 places, those would be considered equal.  Where 0,000001234 is a value
> after a calculation is done.  And the 0,0 is actually 0.0000.   If the significant places used as actually 9, then the
> 0,0 would be 0,000000000.

If 0.000001234 has four significant digits, those digits are the ending 1234, not the first four zeros.  The leading
zeros would only be significant if there was a leadinger non-zero ;)  -- and then the zeros would no longer be leading.

--
~Ethan~

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: OpenPGP digital signature
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20150114/fa5f889f/attachment.sig>


More information about the Python-ideas mailing list