访问量: 10 次浏览
在Scala中,Long是一个64位有符号整数,相当于Java的long原始类型。
利用 /(x: Double) 方法,可以返回这个值与给定值x的商。
方法定义 –
def /(x: Double):Double
返回 –
返回此值与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 = (12.toLong)./(3:Double)
// Displays output
println(result)
}
}
输出:
4.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)./(15:Double)
// Displays output
println(result)
}
}
输出:
11.0