You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Convert a float value `x` into its "shortest" decimal string, which can be parsed back to the same value.
@@ -21,10 +21,12 @@ Various options for the output format include:
21
21
* `plus`: for positive `x`, prefix decimal string with a `'+'` character
22
22
* `space`: for positive `x`, prefix decimal string with a `' '` character; overridden if `plus=true`
23
23
* `hash`: whether the decimal point should be written, even if no additional digits are needed for precision
24
-
* `precision`: minimum number of significant digits to be included in the decimal string; extra `'0'` characters will be added for padding if necessary
24
+
* `precision`: minimum number of digits to be included in the decimal string; extra `'0'` characters will be added for padding if necessary
25
25
* `expchar`: character to use exponent component in scientific notation
26
26
* `padexp`: whether two digits should always be written, even for single-digit exponents (e.g. `e+1` becomes `e+01`)
27
27
* `decchar`: decimal point character to be used
28
+
* `typed`: whether additional type information should be printed for `Float16` / `Float32`
29
+
* `compact`: output will be limited to 6 significant digits
28
30
"""
29
31
functionwriteshortest(x::T,
30
32
plus::Bool=false,
@@ -33,17 +35,19 @@ function writeshortest(x::T,
33
35
precision::Integer=-1,
34
36
expchar::UInt8=UInt8('e'),
35
37
padexp::Bool=false,
36
-
decchar::UInt8=UInt8('.')) where {T <:Base.IEEEFloat}
Convert a float value `x` into a "fixed" size decimal string.
50
+
Convert a float value `x` into a "fixed" size decimal string of the provided precision.
47
51
This function allows achieving the `%f` printf format.
48
52
Note the 2nd method allows passing in a byte buffer and position directly; callers must ensure the buffer has sufficient room to hold the entire decimal string.
49
53
@@ -53,15 +57,22 @@ Various options for the output format include:
53
57
* `hash`: whether the decimal point should be written, even if no additional digits are needed for precision
54
58
* `precision`: minimum number of significant digits to be included in the decimal string; extra `'0'` characters will be added for padding if necessary
55
59
* `decchar`: decimal point character to be used
60
+
* `trimtrailingzeros`: whether trailing zeros should be removed
56
61
"""
57
-
functionwritefixed(x::T, precision) where {T <:Base.IEEEFloat}
62
+
functionwritefixed(x::T,
63
+
precision::Integer,
64
+
plus::Bool=false,
65
+
space::Bool=false,
66
+
hash::Bool=false,
67
+
decchar::UInt8=UInt8('.'),
68
+
trimtrailingzeros::Bool=false) where {T <:Base.IEEEFloat}
Convert a float value `x` into a scientific notation decimal string.
@@ -75,32 +86,38 @@ Various options for the output format include:
75
86
* `precision`: minimum number of significant digits to be included in the decimal string; extra `'0'` characters will be added for padding if necessary
76
87
* `expchar`: character to use exponent component in scientific notation
77
88
* `decchar`: decimal point character to be used
89
+
* `trimtrailingzeros`: whether trailing zeros should be removed
78
90
"""
79
-
functionwriteexp(x::T, precision) where {T <:Base.IEEEFloat}
91
+
functionwriteexp(x::T,
92
+
precision::Integer,
93
+
plus::Bool=false,
94
+
space::Bool=false,
95
+
hash::Bool=false,
96
+
expchar::UInt8=UInt8('e'),
97
+
decchar::UInt8=UInt8('.'),
98
+
trimtrailingzeros::Bool=false) where {T <:Base.IEEEFloat}
0 commit comments