Open In App

Scala Char signum() method with example

Last Updated : 03 Nov, 2019
Improve
Improve
Like Article
Like
Save
Share
Report

The signum() method is utilized to return the Sign function of a Char value passed to it as an argument. If the argument passed is greater than zero, then it will return 1, if its equal to zero then it will return zero, and if its less than zero then it will return -1.

Method Definition: def signum: Int

Return Type: It returns integer.

Example: 1#




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


Output:

1

Example: 2#




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


Output:

1


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads