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