Java Float shortValue() MethodThe shortValue() method of Java Float 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 Float class overrides the shortValue() method of class Number. Return Value:The shortValue() method returns the float value corresponding to this Float which has been converted to type short. Example 1Test it NowOutput: 1. 40.78 after converted to short Value = 40.0 2. -40.78 after converted to short Value = -40 3. 7.4658765E8 after converted to short Value = 1536 4. 0.74658763 after converted to short Value = 0 Example 2Test it NowOutput: Enter your percentage: 89 You % matches with the THIRD cut off list Example 3Test it NowOutput: 1. 1.4E-45 Short value = 0 2. 3.4028235E38 Short value = -1 3. 1.17549435E-38 Short value = 0 4. -Infinity Short value = 0 5. Infinity Short value = -1 6. NaN Short value = 0
Next TopicJava Float
|