[Python-ideas] Suggestion: Extend integers to include iNaN
Steve Barnes
gadgetsteve at live.co.uk
Sun Sep 30 11:17:51 EDT 2018
On 30/09/2018 16:13, David Mertz wrote:
> On Sun, Sep 30, 2018 at 11:01 AM Steve Barnes <gadgetsteve at live.co.uk
> <mailto:gadgetsteve at live.co.uk>> wrote:
>
> Adding inf & -inf would be nice but to do so we would need a better
> name
> than NaNAwareInt.
>
>
> My placeholder name is deliberately awkward. I think it gestures at the
> concept for discussion purposes though.
>
> It would also be nice if Decimal(NaNAwareInt('nan')) = Decimal('NaN'),
> float(NaNAwareInt('nan')) = float('nan'), etc.
>
>
> This seems like bad behavior given (per IEEE-754 spec):
>
> >>> float('nan') == float('nan')
> False
> >>> nan = float('nan')
> >>> nan == nan
> False
>
> --
> Keeping medicines from the bloodstreams of the sick; food
> from the bellies of the hungry; books from the hands of the
> uneducated; technology from the underdeveloped; and putting
> advocates of freedom in prisons. Intellectual property is
> to the 21st century what the slave trade was to the 16th.
David,
Note that my statements above had a single = i.e.
float(NaNAwareInt('nan')) produces float('nan'), etc., as does:
In [42]: nan = decimal.Decimal('nan')
In [43]: decimal.Decimal(nan)
Out[43]: Decimal('NaN')
In [44]: float(nan)
Out[44]: nan
and vice-versa.
--
Steve (Gadget) Barnes
Any opinions in this message are my personal opinions and do not reflect
those of my employer.
---
This email has been checked for viruses by AVG.
https://www.avg.com
More information about the Python-ideas
mailing list