Java Double shortValue() Method10 Nov 2024 | 2 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:Parameters:NA Override:The shortValue() method of Double class overrides the shortValue in class Number. Return Value:The shortValue() method returns the double value corresponding to this Double which has been converted to type short. Example 1Output: 1. 1240.7458 after converted to short Value = 1240 2. -1140.728 after converted to short Value = -1140 3. 7.46587634444444E8 after converted to short Value = 1522 4. 0.746587634 after converted to short Value = 0 Example 2Output: Enter a number = 987654.987 1. Short value =4614 2. Long value =987654 3. Byte value =6 Next TopicJava-double-sum-method |
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 byteValue() method of Java Double class returns the value of this double as a byte after a narrowing primitive conversion. The byteValue () method of class Double overrides the byteValue () method of class Number. Syntax public byte byteValue() Return value This method returns the double value represented by...
3 min read
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 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 compare() method of Java Double class compares two specified double values. Syntax public static int compare(double d1, double d2) Parameters Two parameters- d1- The first double to be compared. d2- The second double to be compared. Return value This method will return value - zero, if d1 is numerically equal to...
3 min read
The sum() method of Double class returns the sum of two double arguments same as the operation performed by '+' operator. Syntax: public static double sum(double a, double b) Parameters: a- the first argument passed b- the second argument passed Return Value: The sum() method returns the sum of a and b. Example 1 import...
2 min read
The equals() method of Java Double class compares this Double object against the specified Double object. The method returns true, if the argument is not null. Assuming d1 and d2 are the two instances of class Double, the value of d1.equals(d2) will be true if d1.doubleValue() == d2.doubleValue...
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 doubleValue() method of Java Double class returns the double value of this Double object. Syntax public double doubleValue() Parameters NA Return value The doubleValue() method returns the double value represented by this object. Example 1 public class Double_doubleValueMethod_Example1 { public static void main(String[] args) { ...
1 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