I have a dynamically changing input reading from a file. The numbers are either Int or Double. Why does Scala print .0 after every D
Int
Double
.0
D
Starting with Scala 2.10 you can use the f interpolator:
scala> val x: Double = 1 x: Double = 1.0 scala> println(f"$x%.0f") 1 scala> val i = 1 i: Int = 1 scala> println(f"$i%.0f") 1