Scala Long %(x: Double) 方法
在 Scala 中,Long 是一个 64 位有符号整数,相当于 Java 的 long 原始类型。当给定的 long 值除以 double 值时, %(x: Double)方法用于返回余数。
Method Definition – def %(x: Double)
Returns – Returns the remainder of the division of this value by x.
示例 #1:
// Scala program to explain the working
// of Long %(x: Double) method
// Creating object
object GfG
{
// Main method
def main(args:Array[String])
{
// Applying %(x: Double) function
val result = (125.toLong).%(13:Double)
// Displays output
println(result)
}
}
输出:
8.0
示例 #2:
// Scala program to explain the working
// of Long %(x: Double) method
// Creating object
object GfG
{
// Main method
def main(args:Array[String])
{
// Applying %(x: Double) function
val result = (165.toLong).%(13:Double)
// Displays output
println(result)
}
}
输出:
9.0