# Print large Int with \_ separators

**URL:** <https://discourse.julialang.org/t/print-large-int-with---separators/6579>\
**Category:** General Usage\
**Tags:** question\
**Created:** [October 20, 2017, 8:29am UTC](https://discourse.julialang.org/t/print-large-int-with---separators/6579 "2017-10-20T08:29:33Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [October 20, 2017, 8:29am UTC](https://discourse.julialang.org/t/print-large-int-with---separators/6579/1 "2017-10-20T08:29:33Z")

</div>

This is part of the read syntax:

```julia
julia> 10_000_000
10000000

```

but how can I print numbers in this format? Just want integers.

PS.: I can work around this with

```julia
julia> using Formatting

julia> replace(format(10^7, commas = true), ",", "_")
"10_000_000"

```

or similar hacks.

---

<div class="post-metadata">

**Author:** ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)\
**Post date:** [October 20, 2017, 8:53am UTC](https://discourse.julialang.org/t/print-large-int-with---separators/6579/2 "2017-10-20T08:53:33Z")

</div>

You can try something like:

```julia
julia> @eval Base begin
           using Formatting
           show(io::IO, i::Signed) = show(io, replace(format(i, commas=true), ",", "_"))
       end;
WARNING: Method definition show(IO, Signed) in module Base at show.jl:259 overwritten at REPL[1]:3.

rand(1:10000, 5, 5)
5×5 Array{Int64,"2"}:
 "6_475" "7_306" "1_793" "2_164" "2_441"
 "7_282" "9_051" "2_813" "5_542" "3_969"
 "6_739" "5_924" "4_357" "1_587" "288"
   "487" "8_289" "9_454" "8_507" "305"
 "4_025" "5_789" "1_285" "1_833" "9_989"

```

It will probably break many things though (including the REPL) 🙂

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [October 20, 2017, 9:07am UTC](https://discourse.julialang.org/t/print-large-int-with---separators/6579/3 "2017-10-20T09:07:44Z")

</div>

Perhaps I was not clear (sorry): I am not looking for a solution to change this everywhere, just to print a specific number. I was just surprised that I could not find anything in `Base` that would support printing in a syntax it reads.

---

<div class="post-metadata">

**Author:** ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)\
**Post date:** [October 20, 2017, 9:11am UTC](https://discourse.julialang.org/t/print-large-int-with---separators/6579/4 "2017-10-20T09:11:49Z")

</div>

In that case, I think something like Formatting is the correct tool.

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [October 20, 2017, 9:17am UTC](https://discourse.julialang.org/t/print-large-int-with---separators/6579/5 "2017-10-20T09:17:40Z")

</div>

Thanks, opened an issue.  
[https://github.com/JuliaIO/Formatting.jl/issues/45](https://github.com/JuliaIO/Formatting.jl/issues/45)

---

<div class="post-metadata">

**Author:** ![dpsanders](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dpsanders/32/3573_2.png) [@dpsanders](https://discourse.julialang.org/u/dpsanders)\
**Post date:** [October 20, 2017, 2:34pm UTC](https://discourse.julialang.org/t/print-large-int-with---separators/6579/6 "2017-10-20T14:34:38Z")

</div>

Have you seen

[https://github.com/IainNZ/Humanize.jl/blob/master/README.md](https://github.com/IainNZ/Humanize.jl/blob/master/README.md)
