Scala Int %(x: Long)方法及示例

Scala Int %(x: Long)方法及示例

利用 % ( x: Long) 方法,当指定的int值除以long值时,可以返回余数。

方法定义:(Int_Value).%(Long_Value)

返回类型。当指定的int值除以long值时,它返回余数。

例子 #1 :

// Scala program of Int %(x: long)
// method
  
// Creating object
object GfG
{ 
  
    // Main method
    def main(args:Array[String])
    {
      
        // Applying Int %(x: long) function
        val result = (100).%(50)
          
        // Displays output
        println(result)
      
    }
} 

输出。

0

例子#2

// Scala program of Int %(x: Long)
// method
  
// Creating object
object GfG
{ 
  
    // Main method
    def main(args:Array[String])
    {
      
        // Applying Int %(x: Long) function
        val result = (100).%(40)
          
        // Displays output
        println(result)
      
    }
} 

输出。

20

Python教程

Java教程

Web教程

数据库教程

图形图像教程

大数据教程

开发工具教程

计算机教程