In Scala, there are mainly 7 numeric types .These numeric types are Byte, Char, Double, Float,Int,Long, and Short. All numeric types are object.
Data ranges of Scala’s built-in numeric types are as follows :-
Above was the brief introduction of numeric data type .
Now , we will see, how can we override the default Numeric Type .
Here, we assign 100 to a variable , Scala assign it the type Int
Scala > val a = 100 a:Int = 100
Overriding simple numeric type
Scala > val a =100F a : Float = 100.0 scala > val a =1000L a:Long =1000
Approach 2 :
Scala > val a= 0:Byte a : Byte = 0 Scala > val a= 0:Int a : Int = 0 Scala > val a= 0:Short a : Short = 0
You can also define the variable types as below
Scala > val a:Int =10 a :Int =10