Skip to content

Commit 078835c

Browse files
TotalVerbStefanKarpinski
authored andcommitted
Document rounding away from zero (#20775)
1 parent b0ca50b commit 078835c

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

base/printf.jl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1196,7 +1196,9 @@ end
11961196
11971197
Print `args` using C `printf()` style format specification string, with some caveats:
11981198
`Inf` and `NaN` are printed consistently as `Inf` and `NaN` for flags `%a`, `%A`,
1199-
`%e`, `%E`, `%f`, `%F`, `%g`, and `%G`.
1199+
`%e`, `%E`, `%f`, `%F`, `%g`, and `%G`. Furthermore, if a floating point number is
1200+
equally close to the numeric values of two possible output strings, the output
1201+
string further away from zero is chosen.
12001202
12011203
Optionally, an `IOStream`
12021204
may be passed as the first argument to redirect output.
@@ -1206,6 +1208,9 @@ may be passed as the first argument to redirect output.
12061208
```jldoctest
12071209
julia> @printf("%f %F %f %F\\n", Inf, Inf, NaN, NaN)
12081210
Inf Inf NaN NaN\n
1211+
1212+
julia> @printf "%.0f %.1f %f\\n" 0.5 0.025 -0.0078125
1213+
1 0.0 -0.007813
12091214
```
12101215
"""
12111216
macro printf(args...)

0 commit comments

Comments
 (0)