double
supports Infinity
double 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
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
Infinity NaN -Infinity
note: Infinity - Infinity
is Not A Number.
Related Posts:
- 1000 * 60 * 60 * 24 * 30 results in a negative number [duplicate]
- Convert String to double in Java
- How do I generate random integers within a specific range in Java?
- Converting double to integer in Java
- How do I generate random integers within a specific range in Java?
- Java JDK – possible lossy conversion from double to int
- Round a double to 2 decimal places [duplicate]
- Round a double to 2 decimal places [duplicate]
- A long bigger than Long.MAX_VALUE
- Round a double to 2 decimal places
- How do I limit the number of decimals printed for a double?
- How do I limit the number of decimals printed for a double?
- How can I properly compare two Integers in Java?
- Double array initialization in Java
- How to check whether a int is not null or empty?
- Declaring an unsigned int in Java
- Unsigned long in Java
- Exception in thread “main” java.lang.NumberFormatException: For input string: “S”
- int cannot be converted to string?
- Double decimal formatting in Java
- Double cannot be dereferenced?
- How can I convert integer into float in Java?
- Converting String Array to an Integer Array
- How can I truncate a double to only two decimal places in Java?
- Java double.MAX_VALUE?
- How to check if the value is integer in java?
- How can I truncate a double to only two decimal places in Java?
- Converting a string to an integer on Android
- Convert an integer to an array of digits
- What do F and D mean at the end of numeric literals?
- Division of integers in Java
- How can I check if a value is of type Integer?
- “Integer number too large” error message for 600851475143
- Java ArrayList of Doubles
- Cannot invoke toString() on the primitive type int
- Why int[] a = new int[1] instead of just int a?
- Why int[] a = new int[1] instead of just int a?
- What is the difference between “Double” and “double” in Java?
- What’s so special about 0x7f?
- Why cannot cast Integer to String in java?
- Convert float to double without losing precision
- Convert double to float in Java
- “Char cannot be dereferenced” error
- Explanation on Integer.MAX_VALUE and Integer.MIN_VALUE to find min and max value in an array
- How to check if a String contains another String in a case insensitive manner in Java?
- Failed to write core dump. minidumps are not enabled by default on client version of windows
- “Missing return statement” within if / for / while
- How to convert byte array to string and vice versa?
- good example of Javadoc
- How do popBackStack() and replace() operations differ?
- Can’t find mysqladmin on Mac OSX 10.6.8
- What is an AssertionError? In which case should I throw it from my own code?
- Java Undefined Object
- Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
- How to convert an ArrayList containing Integers to primitive int array?
- Left Hand Side of an Assignment must be a Variable CharAt
- Compiling a java program into an executable
- Java Installation Not Completed / Unable to install Java
- How to set or change the default Java (JDK) version on macOS?
- How can I create an array of linked lists in java?
- What’s the difference between session.persist() and session.save() in Hibernate?
- This view is not constrained
- Enhanced FOR loops in C++
- How can I create an Array of ArrayLists?
- Create a List of primitive int?
- Compiling error: Return type for the method is missing
- Remove last character of a StringBuilder?
- Why SpringMVC Request method ‘GET’ not supported?
- Error: JAVA_HOME is not defined correctly executing maven
- Eclipse No tests found using JUnit 5 caused by NoClassDefFoundError for LauncherFactory
- Android – SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length
- The specified child already has a parent. You must call removeView() on the child’s parent first (Android)
- HTTP Status 500 Error instantiating servlet class
- How to convert the following json string to java object?
- Java end of file
- A KeyValuePair in Java
- Unclosed Character Literal error
- Java error: void cannot be converted to String
- CreateProcess error=2, The system cannot find the file specified
- Address already in use: JVM_Bind java
- java.lang.ClassNotFoundException:com.mysql.jdbc.Driver [duplicate]
- Using regex to match any character except =
- Why is a ConcurrentModificationException thrown and how to debug it
- How to sort a HashSet?
- Variable used in lambda expression should be final or effectively final
- Populate int array with for loop in Java
- calling boolean method, heads or tails
- Android Color Picker
- How to fix an UnsatisfiedLinkError (Can’t find dependent libraries) in a JNI project
- How to Delete a topic in apache kafka [duplicate]
- Append a single character to a string or char array in java?
- Java printf formatting to print items in a table or columns
- How to resolve “Syntax error on token “else”” in Java?
- What’s the difference between Jetty and Netty?
- Is there a way to simulate the C++ ‘friend’ concept in Java?
- Good way to encapsulate Integer.parseInt()
- String cannot be resolved to a type – Java RAD
- IntelliJ IDEA “The selected directory is not a valid home for JDK”
- Simple timeout in java
- Eclipse message saying List cannot be resolved to a type