Scala Float toShort() method with example
Last Updated :
29 Oct, 2019
The toShort() method is utilized to convert the specified number into Short data type value. The range of the byte data type is from -32, 768 to 32, 767
Method Definition: (Number).toShort
Return Type: It returns the converted Short datatype value.
Example #1:
object GfG
{
def main(args : Array[String])
{
val result = ( 199 ).toShort
println(result)
}
}
|
Example #2:
object GfG
{
def main(args : Array[String])
{
val result = ( 32799 ).toShort
println(result)
}
}
|
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...