Open In App

Scala Float toRadians() method with example

The toRadians() method is utilized to converts an angle measured in degrees to an approximately equivalent angle measured in radians.

Method Definition: (Number).toRadians



Return Type: It returns the converted value of radians.

Example #1:




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

Output:

0.9773844

Example #2:




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

Output:
3.1415927

Article Tags :