Introducing infinity in python

I know that I can define infinity as a float ("inf"). but I'm more interested in its actual implementation. float ("inf") certainly does not return a number. But on it you can make the usual arithmetic comparison. How?

+4
source share
1 answer

Floating point infinity is defined by the IEEE 754 floating point standard . As for the processor, this is a number. It is represented by a bit pattern with all the exponent bits set to 1, all bits in the value set to 0, and the sign bit corresponding to the infinity sign. The floating point circuit in your processor recognizes this bit pattern and understands what to do with infinity or negative infinity as operands. For most operators, this is probably the case with special cases of infinity in the circuit.

+6
source

Source: https://habr.com/ru/post/1541212/


All Articles