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