Scala Double -(x: Short) method with example
In Scala, Double is a 64-bit floating point number, which is equivalent to Java’s double primitive type. The -(x: Short) method is utilized to get the difference of given Double and Short value.
Method Definition – def -(x: Short): Double
Returns – Returns the difference of this value and x.
Example #1:
object GfG
{
def main(args : Array[String])
{
val result = ( 66.00123 ).toDouble.- ( 50 : Short)
println(result)
}
}
|
Output:
16.001230000000007
Example #2:
object GfG
{
def main(args : Array[String])
{
val result = 11.86000000 .toDouble.- ( 5 : Short)
println(result)
}
}
|
Output:
6.859999999999999
Last Updated :
02 Nov, 2019
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...