Java Double compare() Method10 Nov 2024 | 2 min read The compare() method of Java Double class compares two specified double values. SyntaxParametersTwo parameters- d1- The first double to be compared. d2- The second double to be compared. Return valueThis method will return value -
Example 1Output: 10.56 is greater. Difference is= 0.5600000000000005. Example 2Output: Error:(13, 26) java: method compare in class java.lang.Double cannot be applied to given types; required: double,double found: java.lang.Double reason: actual and formal argument lists differ in length Example 3Output: Enter your Family income 45000 Sorry, You are not eligible for the subsidy Next TopicJava-double-compareto-method |
The longValue() method of Java Double class returns the value of this object as a long after narrowing the primitive values or by casting to type long. Syntax public long longValue() Parameters NA Return value The longValue() method returns the double value corresponding to this Double which has been converted to type...
3 min read
The max() method of Java Double class returns the double object having greater value amongst two double values. The result returned is same as by invoking Math.max() method. Syntax public static double max(double a, double b) Parameters Here, a & b are the two operands to be compared ...
4 min read
The isFinite() method of Java Double class returns true if the argument passed is a finite floating-point number, otherwise returns false(in case of NaN and infinity arguments). Syntax public static boolean isFinite(double d) Parameters d- This is the double-precision number to be tested. Return value The isFinite() method returns true when finite...
2 min read
The Double class generally wraps the primitive type double into an object. An object of Double class contains a field with the type Double. Methods: This class is useful in providing various methods like a method which can be used to convert a double to a String and...
3 min read
The hashCode() method of Java Double class returns the hash code for this Double. The result is obtained by performing exclusive OR operation on two halves of the long integer bit representation which is same as produced by the doubleToLongBits() method. Overrides The hashCode() method of class...
3 min read
The min() method of Java Double class returns the double having minor value amongst two double values. The result returned is same as by invoking Math.min () method. Syntax public static double min(double a, double b) Parameters Here, a & b are the two operands to be compared. Return...
6 min read
The intValue() method of Java Double class returns the value of this Double as an int by narrowing the primitive values or by casting to type int. Syntax public int intValue() Parameters NA Return value The intValue() method returns the double value which has been converted to type int. Example 1 import...
1 min read
The longBitsToDouble() method of Java Double class returns the double value equating to an acknowledged bit representation. The result is: Positive infinity, if the argument passed is 0x7ff0000000000000L. Negative infinity, if the argument passed is 0x7ff0000000000000L. Syntax public static double longBitsToDouble(long bits) Parameters bits - is the long integer passed. Return value The...
3 min read
The isInfinite() method of Java Double class will return true if the magnitude of the argument specified is infinitely large, else it will return false. Syntax 1.public boolean isInfinite() 2.public static boolean isInfinite(double v) Parameters 1.NA 2.v- This is the double value which is tested. Return value The isInfnite() method returns true if the...
3 min read
The shortValue() method of Double class returns the value of this object as a short after narrowing the primitive values or by casting to type short. Syntax: public short shortValue() Parameters: NA Override: The shortValue() method of Double class overrides the shortValue in class Number. Return Value: The shortValue() method returns the double value...
2 min read
We request you to subscribe our newsletter for upcoming updates.
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India