Open In App

Scala Float isNaN() method with example

Last Updated : 29 Oct, 2019
Improve
Improve
Like Article
Like
Save
Share
Report

The isNaN() method is utilized to return true if this Float value or the specified float value is Not-a-Number (NaN), or false otherwise.

Method Definition: (Float_Number).isNaN

Return Type: It returns true if this Float value or the specified float value is Not-a-Number (NaN), or false otherwise.

Example #1:




// Scala program of Float isNaN()
// method
  
// Creating object
object GfG
  
    // Main method
    def main(args:Array[String])
    {
      
        // Applying isNaN method
        val result = (0.0/0.0).isNaN
          
        // Displays output
        println(result)
      
    }


Output:

true

Example #2:




// Scala program of Float isNaN()
// method
  
// Creating object
object GfG
  
    // Main method
    def main(args:Array[String])
    {
      
        // Applying isNaN method
        val result = (5.7).isNaN
          
        // Displays output
        println(result)
      
    }


Output:

false


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads