In Scala, Double is a 64-bit floating point number, which is equivalent to Java’s double primitive type. The -(x: Long) method is utilized to get the difference of given Double and Long value.
Method Definition – def -(x: Long): Double
Returns – Returns the difference of this value and x.
Example #1:
// Scala program to explain working // of Double -(x: Long) function // Creating object object GfG
{ // Main method
def main(args : Array[String])
{
// Applying -(x: Long) function
val result = ( 66.01230 ).toDouble.- ( 60 : Long)
// Displays output
println(result)
}
} |
Output:
6.012299999999996
Example #2:
// Scala program to explain working // of Double -(x: Long) function // Creating object object GfG
{ // Main method
def main(args : Array[String])
{
// Applying -(x: Long) function
val result = 11.86000000 .toDouble.- ( 10 : Long)
// Displays output
println(result)
}
} |
Output:
1.8599999999999994
Article Tags :