Understanding is infinite( ) and is NaN( ) Java Help

Understanding is infinite( ) and is NaN( )

Float and Double provide the methods is infinite ) and is NaN( ), which help when manipulating two special double and float values. These methods test for two unique values defined by the EERIE floating-point specification: infinity and NaN (not a ‘ number). is infinite ) returns true if the value being tested is infinitely large or small in magnitude. is NaN( ) returns true if the value being tested is not a number. The following example creates two Double objects; one is infinite, and the other is not a number:

This program generates the following output:
Infinity: true, false
NaN: false, true

Byte, .Short”Integer, and Long

The Byte, Short, Integer, and Long classes are wrappers for byte, short int, and long integer types, respectively. Their constructors are shown here: Byte(byte nunt)
Byte(Strums str) throws Number Format Exception
Short(short num)
Short(String str) throws Number Format Exception
Integer tint unlit)
Integer(String str) throws Number Format Exception
Long(long num)
Long(String. str) throws Number format Exception

As you can see, these objects can be constructed from numeric-values or from strings that contain valid whole number values. The methods defined by these classes are shown in Tables 14-3 through 14-6. As you can see, they define methods for parsing integers from strings an converting strings back into integers. Variants of these methods allow you to specify the radio, or numeric base, for conversion. Common radixes are 2 for binary, 8 for octal, 10 for decimal, and 16 for hexadecimal. The following constants are defined:

JavaHelpOnline.com

  • Feel free to send us an inquiry, we will reply back in hours.
 

Verification

Posted on September 17, 2014 in Exploring java.lang

Share the Story

About the Author

Back to Top
Share This