val num = 42d
Print two decimal places for num
using f
println(f"$num%2.2f")
42.00
Print num
using scientific notation using e
println(f"$num%e")
4.200000e+01
Print num
in hexadecimal with a
println(f"$num%a")
0x1.5p5
Other format strings can be found at https://docs.oracle.com/javase/6/docs/api/java/util/Formatter.html#detail