[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Why does __ne__ exist?

On 01/08/2018 12:36 PM, Thomas Jollans wrote:
> Interesting sentence from that PEP:
> "3. The == and != operators are not assumed to be each other's
> complement (e.g. IEEE 754 floating point numbers do not satisfy this)."
> Does anybody here know how IEE 754 floating point numbers need __ne__?

That's very interesting. I'd also like an answer to this. I can't wrap
my head around why it would be true. I've just spent 15 minutes playing
with the interpreter (i.e. checking operations on 0, -0, 7,
float('nan'), float('inf'), etc.) and then also reading a bit about IEEE
754 online and I can't find any combination of examples where == and !=
are not each others' complement.