Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • isNaN() And isInfinite() in Java

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 191
    Comment on it

    isNaN() and isInfinite() methods in Java are the member functions of the java.lang.Double and java.lang.Float classes. Both the functions here are static member functions of the classes.

    NaN here stands for the Not-a-Number, it specifies whether the constant holding the value is a number or not. It always returns false for the values like any value parsed as a string.

    The isInfinite() methods only check for the value as finite or infinite, but the isNaN() method performs to check the type of the value passed, It doesn't matter if the value is infinite or not.

    for example :

    isNaN(1) //false 
    isInfinite(2000) // false
    
    isNaN("1") //True
    isInfinite(0/0)  // True
    

    if the argument is not a number then isNaN() returns true, otherwise it will be false. if the argument is finite then isinfinite() returns false, otherwise if it is infinite then it will return true .

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: