Skip to content

Commit ee4a441

Browse files
jmkuhnstevengj
authored andcommitted
Change write() to print() (#68)
1 parent 0722b5b commit ee4a441

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

src/DecFP.jl

+16-16
Original file line numberDiff line numberDiff line change
@@ -182,12 +182,12 @@ for w in (32,64,128)
182182
end
183183

184184
function Base.show(io::IO, x::$BID)
185-
isnan(x) && (write(io, "NaN"); return)
186-
isinf(x) && (write(io, signbit(x) ? "-Inf" : "Inf"); return)
187-
x == 0 && (write(io, signbit(x) ? "-0.0" : "0.0"); return)
185+
isnan(x) && (print(io, "NaN"); return)
186+
isinf(x) && (print(io, signbit(x) ? "-Inf" : "Inf"); return)
187+
x == 0 && (print(io, signbit(x) ? "-0.0" : "0.0"); return)
188188
tostring(x)
189189
if _buffer[1] == UInt8('-')
190-
write(io, '-')
190+
print(io, '-')
191191
end
192192
normalized_exponent = exponent10(x)
193193
lastdigitindex = Compat.findfirst(isequal(UInt8('E')), _buffer) - 1
@@ -197,29 +197,29 @@ for w in (32,64,128)
197197
if normalized_exponent >= 0
198198
if normalized_exponent >= lastnonzeroindex - 2
199199
GC.@preserve _buffer unsafe_write(io, pointer(_buffer, 2), lastnonzeroindex - 1)
200-
writezeros(io, normalized_exponent - lastnonzeroindex + 2)
201-
write(io, ".0")
200+
printzeros(io, normalized_exponent - lastnonzeroindex + 2)
201+
print(io, ".0")
202202
else
203203
GC.@preserve _buffer unsafe_write(io, pointer(_buffer, 2), normalized_exponent + 1)
204-
write(io, '.')
204+
print(io, '.')
205205
GC.@preserve _buffer unsafe_write(io, pointer(_buffer, normalized_exponent + 3), lastnonzeroindex - normalized_exponent - 2)
206206
end
207207
else
208-
write(io, "0.")
209-
writezeros(io, -normalized_exponent - 1)
208+
print(io, "0.")
209+
printzeros(io, -normalized_exponent - 1)
210210
GC.@preserve _buffer unsafe_write(io, pointer(_buffer, 2), lastnonzeroindex - 1)
211211
end
212212
else
213213
# %e
214-
write(io, _buffer[2], '.')
214+
print(io, Char(_buffer[2]), '.')
215215
if lastnonzeroindex == 2
216-
write(io, '0')
216+
print(io, '0')
217217
else
218218
GC.@preserve _buffer unsafe_write(io, pointer(_buffer, 3), lastnonzeroindex - 2)
219219
end
220-
write(io, 'e')
220+
print(io, 'e')
221221
if normalized_exponent < 0
222-
write(io, '-')
222+
print(io, '-')
223223
normalized_exponent = -normalized_exponent
224224
end
225225
b_lb = div(normalized_exponent, 10)
@@ -230,7 +230,7 @@ for w in (32,64,128)
230230
r = normalized_exponent
231231
while b > 0
232232
q, r = divrem(r, b)
233-
write(io, UInt8('0') + (q%UInt8))
233+
print(io, '0' + q)
234234
b = div(b, 10)
235235
end
236236
end
@@ -479,9 +479,9 @@ macro d64_str(s, flags...) parse(Dec64, s) end
479479
macro d128_str(s, flags...) parse(Dec128, s) end
480480

481481
# for zero-padding in printing routines above
482-
function writezeros(io::IO, n::Int)
482+
function printzeros(io::IO, n::Int)
483483
for i = 1:n
484-
write(io, UInt8('0'))
484+
print(io, '0')
485485
end
486486
end
487487

0 commit comments

Comments
 (0)