33module Printf
44using Base: Grisu, GMP
55using Base. Unicode: lowercase, textwidth, isupper
6- export @printf , @sprintf
76
87# ## printf formatter generation ###
98const SmallFloatingPoint = Union{Float64,Float32,Float16}
@@ -1193,27 +1192,6 @@ function _printf(macroname, io, fmt, args)
11931192 Expr (:let , Expr (:block ), blk)
11941193end
11951194
1196- """
1197- @printf([io::IOStream], "%Fmt", args...)
1198-
1199- Print `args` using C `printf` style format specification string, with some caveats:
1200- `Inf` and `NaN` are printed consistently as `Inf` and `NaN` for flags `%a`, `%A`,
1201- `%e`, `%E`, `%f`, `%F`, `%g`, and `%G`. Furthermore, if a floating point number is
1202- equally close to the numeric values of two possible output strings, the output
1203- string further away from zero is chosen.
1204-
1205- Optionally, an `IOStream`
1206- may be passed as the first argument to redirect output.
1207-
1208- # Examples
1209- ```jldoctest
1210- julia> @printf("%f %F %f %F\\ n", Inf, Inf, NaN, NaN)
1211- Inf Inf NaN NaN\n
1212-
1213- julia> @printf "%.0f %.1f %f\\ n" 0.5 0.025 -0.0078125
1214- 1 0.0 -0.007813
1215- ```
1216- """
12171195macro printf (args... )
12181196 isempty (args) && throw (ArgumentError (" @printf: called with no arguments" ))
12191197 if isa (args[1 ], AbstractString) || is_str_expr (args[1 ])
@@ -1225,19 +1203,6 @@ macro printf(args...)
12251203 end
12261204end
12271205
1228- """
1229- @sprintf("%Fmt", args...)
1230-
1231- Return `@printf` formatted output as string.
1232-
1233- # Examples
1234- ```jldoctest
1235- julia> s = @sprintf "this is a %s %15.1f" "test" 34.567;
1236-
1237- julia> println(s)
1238- this is a test 34.6
1239- ```
1240- """
12411206macro sprintf (args... )
12421207 isempty (args) && throw (ArgumentError (" @sprintf: called with zero arguments" ))
12431208 isa (args[1 ], AbstractString) || is_str_expr (args[1 ]) ||
0 commit comments