当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


Scala Float isValidInt()用法及代码示例


如果指定的数字为零或在scala范围内,则使用isValidInt()方法返回true。否则返回false。

函数定义: (Float_Number).isValidInt

返回类型: It returns true if the specified number is either zero or lies within the range of scala.Int MinValue and MaxValue; otherwise returns false.



范例1:

// Scala program of Float isValidInt() 
// method 
  
// Creating object 
object GfG 
{  
  
    // Main method 
    def main(args:Array[String]) 
    { 
      
        // Applying isValidInt method 
        val result = (0).isValidInt 
          
        // Displays output 
        println(result) 
      
    } 
} 
输出:
true

范例2:

// Scala program of Float isValidInt() 
// method 
  
// Creating object 
object GfG 
{  
  
    // Main method 
    def main(args:Array[String]) 
    { 
      
        // Applying isValidInt method 
        val result = (5.9).isValidInt 
          
        // Displays output 
        println(result) 
      
    } 
} 
输出:
false


相关用法


注:本文由纯净天空筛选整理自Kanchan_Ray大神的英文原创作品 Scala Float isValidInt() method with example。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。