Mozzer Mozzer - 1 year ago 86
Scala Question

How can i format a float variable in scala?

i need to format this variable :

val value = 3.2202

in a number like this: 3.2

How can i make this in scala?
I don't want a string or a println...I need another float variable with 1 decimal.

Answer Source
val floatVal = BigDecimal(3.2202).setScale(1, BigDecimal.RoundingMode.HALF_DOWN).toFloat
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download