# Format.jl (based on JuliaIO/Formatting.jl)

**URL:** <https://discourse.julialang.org/t/format-jl-based-on-juliaio-formatting-jl/1740>\
**Category:** Community\
**Tags:** formatting\
**Created:** [January 28, 2017, 3:45pm UTC](https://discourse.julialang.org/t/format-jl-based-on-juliaio-formatting-jl/1740 "2017-01-28T15:45:02Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ScottPJones](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/scottpjones/32/146_2.png) [@ScottPJones](https://discourse.julialang.org/u/ScottPJones)\
**Post date:** [January 28, 2017, 3:45pm UTC](https://discourse.julialang.org/t/format-jl-based-on-juliaio-formatting-jl/1740/1 "2017-01-28T15:45:02Z")

</div>

[GitHub - JuliaString/Format.jl: A Julia package to provide C and Python-like formatting support](https://github.com/JuliaString/Format.jl) is now available (although it is unregistered currently).  
It is based on [GitHub - JuliaIO/Formatting.jl: A Julia package to provide Python-like formatting support](https://github.com/JuliaIO/Formatting.jl), however it has dropped v0.4 support, and added support for v0.6-dev.

This (renamed) fork adds the type specific defaults from @tbreloff’s PR:

> <https://github.com/JuliaIO/Formatting.jl/pull/10>
>
> I don't intend this to be merged as-is, but I want to start a discussion as to w…hether this approach will make sense. See the embedded TODO's for some ways that I would expect a final version to be different. You can see some example usage in tests/fmt.jl. Let me know your comments, and please... be brutal.

renames `fmt` to `pyfmt` (Python Format) and `sprintf1` to `cfmt` (C format) (`fmt` is use for type specific output with defaults from Tom’s PR).

I use this package for all the formatted printing support in my package:

> **[GitHub - JuliaString/StringLiterals.jl: Implement improved string literals...](https://github.com/JuliaString/StringLiterals.jl)**
>
> Implement improved string literals with Swift-style syntax for interpolation, hex, & unicode characters, plus C & Python style formatting and Unicode, HTML, LaTeX, and Emoji entities - GitH...

Note: I have also submitted a PR [Fix issue #27, world age problem on v0.6 by ScottPJones · Pull Request #30 · JuliaIO/Formatting.jl · GitHub](https://github.com/JuliaIO/Formatting.jl/pull/30) to make the original Formatting package work on v0.6, if anybody with commit privileges in the JuliaIO org sees this, it’s passing all of the tests and is ready to merge.

---

<div class="post-metadata">

**Author:** ![yakir12](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yakir12/32/297_2.png) [@yakir12](https://discourse.julialang.org/u/yakir12)\
**Post date:** [June 5, 2018, 11:24am UTC](https://discourse.julialang.org/t/format-jl-based-on-juliaio-formatting-jl/1740/2 "2018-06-05T11:24:24Z")

</div>

How can I submit an issue on your package? Probably cause I was looking at a branch. Posted [this issue](https://github.com/JuliaIO/Formatting.jl/issues/65) on `Formatting.jl` as well. [edited: now closed]  
In any case:

```julia
julia> s = format(111222333444555666, commas=true, precision = 2 , stripzeros = true )
"111,222,333,444,555,666"

julia> s = format(111222333444555666.01, commas=true, precision = 2 , stripzeros = true )
"111,222,333,444,555,664" # <= shouldn't this be "111,222,333,444,555,666.01"?

```

---

<div class="post-metadata">

**Author:** ![ScottPJones](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/scottpjones/32/146_2.png) [@ScottPJones](https://discourse.julialang.org/u/ScottPJones)\
**Post date:** [June 5, 2018, 11:53am UTC](https://discourse.julialang.org/t/format-jl-based-on-juliaio-formatting-jl/1740/3 "2018-06-05T11:53:41Z")

</div>

That’s not a bug with format, the issue is binary floating point only has 53 bits for the value (really 52, but there’s actually an assumed leading 1 bit for all except subnormal numbers). The rest of the bits are for the sign bit and a biased exponent.

```julia
julia> x = 111222333444555666.01
1.1122233344455566e17

julia> nextfloat(x)
1.1122233344455568e17

```

---

<div class="post-metadata">

**Author:** ![yakir12](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yakir12/32/297_2.png) [@yakir12](https://discourse.julialang.org/u/yakir12)\
**Post date:** [June 5, 2018, 11:57am UTC](https://discourse.julialang.org/t/format-jl-based-on-juliaio-formatting-jl/1740/4 "2018-06-05T11:57:40Z")

</div>

Yap, sorry for the noise:

```julia
julia> 111222333444555666.01 == 111222333444555664
true

```
