@@ -97,15 +97,15 @@ function addcommas( s::ASCIIString )
97
97
end
98
98
99
99
function generate_format_string (;
100
- width= nothing ,
101
- precision= - 1 ,
102
- leftjustified= false ,
103
- zeropadding= false ,
104
- commas= false ,
105
- signed= false ,
106
- positivespace= false ,
107
- alternative= false ,
108
- conversion= " f" # aAdecEfFiosxX
100
+ width:: Int = - 1 ,
101
+ precision:: Int = - 1 ,
102
+ leftjustified:: Bool = false ,
103
+ zeropadding:: Bool = false ,
104
+ commas:: Bool = false ,
105
+ signed:: Bool = false ,
106
+ positivespace:: Bool = false ,
107
+ alternative:: Bool = false ,
108
+ conversion:: ASCIIString = " f" # aAdecEfFiosxX
109
109
)
110
110
s = " %"
111
111
if commas
@@ -114,7 +114,7 @@ function generate_format_string(;
114
114
if alternative && in ( conversion[1 ], " aAeEfFoxX" )
115
115
s *= " #"
116
116
end
117
- if zeropadding && ! leftjustified && width != nothing
117
+ if zeropadding && ! leftjustified && width != - 1
118
118
s *= " 0"
119
119
end
120
120
@@ -124,7 +124,7 @@ function generate_format_string(;
124
124
s *= " "
125
125
end
126
126
127
- if width != nothing
127
+ if width != - 1
128
128
if leftjustified
129
129
s *= " -" * string ( width )
130
130
else
@@ -138,8 +138,8 @@ function generate_format_string(;
138
138
end
139
139
140
140
function format {T<:Real} ( x:: T ;
141
- width= nothing ,
142
- precision= - 1 ,
141
+ width:: Int = - 1 ,
142
+ precision:: Int = - 1 ,
143
143
leftjustified:: Bool = false ,
144
144
zeropadding:: Bool = false , # when right-justified, use 0 instead of space to fill
145
145
commas:: Bool = false ,
@@ -149,12 +149,12 @@ function format{T<:Real}( x::T;
149
149
parens:: Bool = false , # use (1.00) instead of -1.00. Used in finance
150
150
alternative:: Bool = false , # usually for hex
151
151
mixedfraction:: Bool = false ,
152
- mixedfractionsep= " _" ,
153
- fractionsep= " /" , # num / den
152
+ mixedfractionsep:: String = " _" ,
153
+ fractionsep:: String = " /" , # num / den
154
154
fractionwidth:: Int = 0 ,
155
- tryden = 0 , # if 2 or higher, try to use this denominator, without losing precision
156
- suffix= " " , # useful for units/%
157
- autoscale= :none , # :metric, :binary or :finance
155
+ tryden:: Int = 0 , # if 2 or higher, try to use this denominator, without losing precision
156
+ suffix:: String = " " , # useful for units/%
157
+ autoscale:: Symbol = :none , # :metric, :binary or :finance
158
158
conversion:: ASCIIString = " "
159
159
)
160
160
checkwidth = commas
@@ -342,7 +342,7 @@ function format{T<:Real}( x::T;
342
342
checkwidth = true
343
343
end
344
344
345
- if checkwidth && width != nothing
345
+ if checkwidth && width != - 1
346
346
if length (s) > width
347
347
s = replace ( s, " " , " " , length (s)- width )
348
348
if length (s) > width && endswith ( s, " " )
0 commit comments