# Compact float printing in the REPL

**URL:** <https://discourse.julialang.org/t/compact-float-printing-in-the-repl/4561>\
**Category:** General Usage\
**Created:** [June 30, 2017, 10:23am UTC](https://discourse.julialang.org/t/compact-float-printing-in-the-repl/4561 "2017-06-30T10:23:44Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![mauro3](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mauro3/32/292_2.png) [@mauro3](https://discourse.julialang.org/u/mauro3)\
**Post date:** [August 31, 2018, 1:23pm UTC](https://discourse.julialang.org/t/compact-float-printing-in-the-repl/4561/5 "2018-08-31T13:23:26Z")

</div>

You can redefine the show method for float. `@which show(stdout, 2/3)` shows you where it is, `@less` prints it. This modification might work:

```julia
julia> function Base.show(io::IO, x::Union{Float64,Float32})
                 Base.Grisu._show(io, round(x, sigdigits=3), Base.Grisu.SHORTEST, 0, get(io, :typeinfo, Any) !== typeof(x), false)
         end                                                                                                                                                            
                                                                                                                                                                        
julia> 2/3                                                                                                                                                              
0.667                                                                                                                                                                   

julia> rand(10)                                                                                                                                                         
10-element Array{Float64,1}:                                                                                                                                            
 0.684                                                                                                                                                                  
 0.594                                                                                                                                                                  
 0.0643
 0.695                                                                                                                                                                  
 0.524                                                                                                                                                                  
 0.884                                                                                                                                                                  
 0.541                                                                                                                                                                  
 0.49                                                                                                                                                                   
 0.175                                                                                                                                                                  
 0.561                                                                                                                                                                  

```

(Note, there is a certain danger in redefining Base-methods! But should be ok for `show`)

---

_[View the full topic](https://discourse.julialang.org/t/compact-float-printing-in-the-repl/4561)._
