Scala Float toByte() method with example
The toByte() method is utilized to convert the specified number into Byte data type value. The range of the byte data type is from -128 to 127.
Method Definition: (Number).toByte
Return Type: It returns the converted byte datatype value.
Example #1:
// Scala program of Float toByte() // method // Creating object object GfG { // Main method def main(args : Array[String]) { // Applying toByte method val result = ( 66 ).toByte // Displays output println(result) } } |
Output:
66
Example #2:
// Scala program of Float toByte() // method // Creating object object GfG { // Main method def main(args : Array[String]) { // Applying toByte method val result = ( 129 ).toByte // Displays output println(result) } } |
Output:
-127