Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is -inf really?

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

from math import inf
like image 289
TheSwimster Avatar asked Mar 12 '26 01:03

TheSwimster


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

like image 165
templatetypedef Avatar answered Mar 13 '26 15:03

templatetypedef



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!