Like C/C++ have the INT_MAX macro (#include<limits.h>) to set a variable to INFINITY.
I was wondering if there is a similar function/macro in JAVA. I want to set an integer variable to INFINITY.
Thanks in advance !!
Like C/C++ have the INT_MAX macro (#include<limits.h>) to set a variable to INFINITY.
I was wondering if there is a similar function/macro in JAVA. I want to set an integer variable to INFINITY.
Thanks in advance !!
The static MAX_VALUE variable of the Integer class is what you want.
Integer.MAX_VALUE
However, this isn't as useful in Java, since int values in Java are 32 bits no matter what.
Go to the following web page to learn more about the Integer class:
https://docs.oracle.com/javase/7/docs/api/java/lang/Integer.html
Java doesn't supports infinity in int type. The only way to represent an infinity number in Java is with the double type:
double infinity = Double.POSITIVE_INFINITY;
Look at here: https://docs.oracle.com/javase/7/docs/api/java/lang/Double.html#POSITIVE_INFINITY