How to implement infinity in Java?

double supports Infinity Add New Post Add titleHow to implement infinity in Java? double supports Infinitydouble inf = Double.POSITIVE_INFINITY; System.out.println(inf + 5); System.out.println(inf – inf); // same as Double.NaN System.out.println(inf * -1); // same as Double.NEGATIVE_INFINITY printsInfinity NaN -Infinity prints note: Infinity – Infinity is Not A Number.

Infinite integer in Python

Taken from here: https://www.gnu.org/software/libc/manual/html_node/Infinity-and-NaN.html IEEE 754 floating point numbers can represent positive or negative infinity, and NaN (not a number) That is, the representation of float and Decimal can store these special values. However, there is nothing within the basic type int that can store the same. As you exceed the limit of 2^32 in an unsigned 32-bit int, you simply roll … Read more

Setting an int to Infinity in C++

Integers are finite, so sadly you can’t have set it to a true infinity. However you can set it to the max value of an int, this would mean that it would be greater or equal to any other int, ie: is always true. You would do this by This will normally be equal to … Read more