Formatting.jl icon indicating copy to clipboard operation
Formatting.jl copied to clipboard

skip decimal point when 0 decimal digits are requested

Open alusiani opened this issue 5 years ago • 2 comments

When no decimal digits are requested, no decimal digits are formatted, but the decimal point is still included. This is different from printf in C and from format in Python, which omit the decimal point in this case.

Example in Python:

"{:.0f}".format(123.4)
## result: '123'

Example in Julia

using Formatting
fmt(".0f", 123.4)
## result: "123."
format("{:.0f}", 123.4)
## result: "123."

Would it be possible to change this behaviour and make it the same as C printf() and Python format()?

alusiani avatar Dec 26 '20 17:12 alusiani

I second this request! This discrepancy has led to nasty bugs in a workflow of mine that combines Python and Julia scripts.

sbrisard avatar Nov 24 '21 17:11 sbrisard