Scala Long %(x: Short)方法

Scala Long %(x: Short)方法

在Scala中,Long是一个64位有符号整数,相当于Java的long原始类型。利用 % ( x: Short) 方法,当给定的long值除以Short值时,可以返回余数。

方法定义 – def %(x: Short)

返回 – 返回该值除以x的余数。

例子 #1 :

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

输出

9

例子#2

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

输出

0

Python教程

Java教程

Web教程

数据库教程

图形图像教程

大数据教程

开发工具教程

计算机教程