Skip to content

Commit

Permalink
printf: complete support for BigInts (implemented ini_dec) [#5756]
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanKarpinski committed Mar 7, 2014
1 parent dd08c0d commit 2fb42e5
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions base/printf.jl
Original file line number Diff line number Diff line change
Expand Up @@ -726,6 +726,25 @@ function ini_dec(x::SmallFloatingPoint, n::Int)
end
end

function ini_dec(x::BigInt, n::Int)
if x.size == 0
POINT[1] = 1
NEG[1] = false
ccall(:memset, Ptr{Void}, (Ptr{Void}, Cint, Csize_t), DIGITS, '0', n)
else
d = Base.ndigits0z(x)
if d <= n
int_dec(x)
d == n && return
p = convert(Ptr{Void}, DIGITS) + POINT[1]
ccall(:memset, Ptr{Void}, (Ptr{Void}, Cint, Csize_t), p, '0', n - POINT[1])
else
int_dec(iround(x/big(10)^(d-n)))
POINT[1] = d
end
end
end

### external printf interface ###

is_str_expr(ex) =
Expand Down

0 comments on commit 2fb42e5

Please sign in to comment.