📜  Scala Double %(x: Long) 方法

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

Scala Double %(x: Long) 方法

在 Scala 中,Double 是一个 64 位浮点数,相当于 Java 的 double 基本类型。当给定的 Double 值除以 Long 值时, %(x: Long)方法用于返回余数。

示例 #1:

// Scala program to explain the working 
// of Double %(x: Long) method
   
// Creating object
object GfG
{ 
   
    // Main method
    def main(args:Array[String])
    {
       
        // Applying %(x: Long) function
        val result = (12.01255.toDouble ).%(8:Long)
           
        // Displays output
        println(result)
       
    }
}
输出:
4.012549999999999

示例 #2:

// Scala program to explain the working 
// of Double %(x: Long) method
   
// Creating object
object GfG
{ 
   
    // Main method
    def main(args:Array[String])
    {
       
        // Applying %(x: Long) function
        val result = (16.50012.toDouble ).%(13:Long)
           
        // Displays output
        println(result)
       
    }
}
输出:
3.500119999999999