Customize a floating type to display different precisions
Hello, everyone
I want to customize a floating type to display three decimal places, such as displaying 3.141
I have used the following sentence before
show(io::IO, e::Float32) = print(io, @sprintf(“%.2f”, e))
So the following has warning
const ff33 = Float32
show(io::IO, e::ff33) = print(io, @sprintf(“%.3f”, e))
primitive type ff33 <: AbstractFloat 32 end
This definition is ok, but the type conversion of ff33 and Float32 has to be processed
Is there the easiest way to customize the display of three decimal places?
Can someone help me with this?