Scala Double %(x: Int) 方法
在 Scala 中,Double 是一个 64 位浮点数,相当于 Java 的 double 基本类型。当给定的 Double 值除以 Int 值时, %(x: Int)方法用于返回余数。
Method Definition – def %(x: Int)
Returns – Returns the remainder of the division of this value by x.
示例 #1:
// Scala program to explain the working
// of Double %(x: Int) method
// Creating object
object GfG
{
// Main method
def main(args:Array[String])
{
// Applying %(x: Int) function
val result = (10.021550.toDouble ).%(3:Int)
// Displays output
println(result)
}
}
输出:
1.0215499999999995
示例 #2:
// Scala program to explain the working
// of Double %(x: Int) method
// Creating object
object GfG
{
// Main method
def main(args:Array[String])
{
// Applying %(x: Int) function
val result = (16.50021.toDouble ).%(13:Int)
// Displays output
println(result)
}
}
输出:
3.500209999999999