Why are floating point infinities, unlike NaNs, equal?

Your reasoning is that Double.POSITIVE_INFINITY should not be equal to itself because it is “likely” to have been obtained as the result of a loss of accuracy. This line of reasoning applies to all of floating-point. Any finite value can be obtained as the result of an inaccurate operation. That did not push the IEEE … Read more

Why is log(inf + inf j) equal to (inf + 0.785398 j), In C++/Python/NumPy?

The free final draft of the C99 specification says on page 491 clog(+∞, +i∞) returns +∞ + iπ/4. This is still the case currently. The C++ specification explains the same rules with the note The semantics of this function are intended to be consistent with the C function clog. I agree the behaviour is confusing … Read more

In JavaScript, why does zero divided by zero return NaN, but any other divided by zero return Infinity?

Because that’s how floating-point is defined (more generally than just Javascript). See for example: http://en.wikipedia.org/wiki/Floating-point#Infinities http://en.wikipedia.org/wiki/NaN#Creation Crudely speaking, you could think of 1/0 as the limit of 1/x as x tends to zero (from the right). And 0/0 has no reasonable interpretation at all, hence NaN.

Infinite integer in Python

You are right that an integer infinity is possible, and that none has been added to the Python standard. This is probably because math.inf supplants it in almost all cases (as Martijn stated in his comment). In the meantime, I added an implementation of extended integers on PyPI: In [0]: from numbers import Integral, Real … Read more

Setting an int to Infinity in C++

Integers are inherently finite. The closest you can get is by setting a to int‘s maximum value: #include <limits> // … int a = std::numeric_limits<int>::max(); Which would be 2^31 – 1 (or 2 147 483 647) if int is 32 bits wide on your implementation. If you really need infinity, use a floating point number … Read more

How to express infinity in Ruby?

If you use ruby 1.9.2, you can use: >> Float::INFINITY #=> Infinity >> 3 < Float::INFINITY #=> true Or you can create your own constant using the following*: I’ve checked that in Ruby 1.8.6, 1.8.7, and 1.9.2 you have Float.infinite?. PositiveInfinity = +1.0/0.0 => Infinity NegativeInfinity = -1.0/0.0 => -Infinity CompleteInfinity = NegativeInfinity..PositiveInfinity => -Infinity..Infinity … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)