[Python-ideas] Suggestion: Extend integers to include iNaN

Steve Barnes gadgetsteve at live.co.uk
Sat Sep 29 04:43:44 EDT 2018



On 29/09/2018 08:50, Serhiy Storchaka wrote:
> 29.09.18 10:35, Steve Barnes пише:
>> On 29/09/2018 08:24, Serhiy Storchaka wrote:
>>> 29.09.18 09:31, Steve Barnes пише:
>>>> I think that it should be relatively simple to extend the Python 
>>>> integer
>>>> class to have a NaN flag, possibly by having a bit length of 0, and 
>>>> have
>>>> it follow the same rules for the handling of floating point NaN, i.e.
>>>> any mathematical operation on an iNaN returns an iNaN and any 
>>>> comparison
>>>> with one returns False.
>>>
>>> How does it differ from float('nan')?
>>>
>> It is still an integer and would pass through any processing that
>> expected an integer as one, (with a value of iNaN).
> 
> Python is dynamically typed language. What is such processing that would 
> work with iNaN, but doesn't work with float('nan')?
> 
One simplistic example would be print(int(float('nan'))) (gives a 
ValueError) while print(int(iNaN)) should give 'nan' or maybe 'inan'.

-- 
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