Scala string interpolation formats actually use java's Formatter behind the scenes .
The format string has the following format :
%[argument_index$][flags][width][.precision]conversion
In your case the format string is using a float
conversion ( the f
at the end)
So your format string is asking for a float conversion with a width of 2
and a precision of 2
In the same way %4.10f
would request a float conversion with a width of 4
and a precision of 10
.
- Passing
1.9d
to the format String %4.10f
would result in the string
1,9000000000
- Passing
1.9d
to the format String %10.4f
would result in the string
1,9000
(it would be padded to a width of 10 with whitespace)