What is -inf really?

Viewed 69

Is this just the smallest number that can be stored in 32 bits for example?

from math import inf
1 Answers

Floating-point numbers (real numbers as typically implemented on a computer) have special values reserved for positive and negative infinity. Rather than just being “the largest or smallest representable 32-bit numbers,” they act as though they really are infinite. For example, adding anything to positive infinity (other than negative infinity) gives positive infinity, and a similar rule holds for negative infinity.

For more on this, do a search for “IEEE-754 infinity.”

Related