如果指定的數字為零或在scala範圍內,則使用isValidShort()方法返回true。否則返回false。
函數定義: (Float_Number).isValidShort
返回類型: It returns true if the specified number is either zero or lies within the range of scala.Short MinValue and MaxValue; otherwise returns false.
範例1:
// Scala program of Float isValidShort() 
// method 
  
// Creating object 
object GfG 
{  
  
    // Main method 
    def main(args:Array[String]) 
    { 
      
        // Applying isValidShort method 
        val result = (0).isValidShort 
          
        // Displays output 
        println(result) 
      
    } 
} 
輸出:
true
範例2:
// Scala program of Float isValidShort() 
// method 
  
// Creating object 
object GfG 
{  
  
    // Main method 
    def main(args:Array[String]) 
    { 
      
        // Applying isValidShort method 
        val result = (5.9).isValidShort 
          
        // Displays output 
        println(result) 
      
    } 
} 
輸出:
false
相關用法
- Scala Int isValidShort()用法及代碼示例
- Scala Char isValidShort()用法及代碼示例
- Scala Float to(end: Float, step: Float)用法及代碼示例
- Scala Float until(end: Float, step: Float)用法及代碼示例
注:本文由純淨天空篩選整理自Kanchan_Ray大神的英文原創作品 Scala Float isValidShort() method with example。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。
