📜  Scala Float unary_- 方法与示例

📅  最后修改于: 2022-05-13 01:55:06.115000             🧑  作者: Mango

Scala Float unary_- 方法与示例

unary_-方法用于返回带有负号的相同指定浮点值。

示例 #1:

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


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


输出:
-65.0

示例 #2:

斯卡拉

// Scala program of Float unary_-
// method
 
// Creating object
object GfG
{
 
    // Main method
    def main(args:Array[String])
    {
     
        // Applying unary_- function
        val result = (115.9).unary_-
         
        // Displays output
        println(result)
     
    }
}
输出:
-115.9