julia> Base.active_repl.options.iocontext[:compact]=true
true
julia> e = exp(1)
2.71828
julia> @show e;
e = 2.718281828459045
1 Like
Try:
using Printf
Base.show(io::IO, f::Float64) = @printf(io, "%.5f", f)
1 Like
well, better
using Printf
Base.show(io::IO, f::Float64) = @printf(io, "%5g", f)
otherwise small numbers are shown as zeros
2 Likes
The next question. After I had set the compact display as above, I needed an exact value of a variable. How can I get it?
julia> x = 0.012345678901234
0.012345678901234
julia> using Printf
julia> Base.show(io::IO, f::Float64) = @printf(io, "%5g", f)
julia> x
0.0123457
julia> Base.show(io::IO, f::Float64) = @printf(io, "%15g", f)
julia> x
0.0123457 # the only difference now it's displayed with an offset
A workaround solution to my question above:
julia> x = 0.012345678901234
0.0123457
julia> string(x)
"0.012345678901234"