Skip to content

Commit

Permalink
Merge pull request #11571 from pabloferz/pz/mpfr
Browse files Browse the repository at this point in the history
Avoid the printing of e+00
  • Loading branch information
StefanKarpinski committed Jun 4, 2015
2 parents 5ea501d + bab15fa commit c09aebf
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions base/mpfr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -768,14 +768,13 @@ function string(x::BigFloat)
lng::Int32 = 127
buf = Array(UInt8, lng + 1)
lng = ccall((:mpfr_snprintf,:libmpfr), Int32, (Ptr{UInt8}, Culong, Ptr{UInt8}, Ptr{BigFloat}...), buf, lng + 1, "%.Re", &x)
(84 <= lng <= 127) && return bytestring(pointer(buf), 1 <= x < 10 ? lng-4 : lng)
if lng < 84 # print at least 78 decimal places
lng = ccall((:mpfr_sprintf,:libmpfr), Int32, (Ptr{UInt8}, Ptr{UInt8}, Ptr{BigFloat}...), buf, "%.78Re", &x)
else
elseif lng > 127
buf = Array(UInt8, lng + 1)
lng = ccall((:mpfr_snprintf,:libmpfr), Int32, (Ptr{UInt8}, Culong, Ptr{UInt8}, Ptr{BigFloat}...), buf, lng + 1, "%.Re", &x)
end
return bytestring(pointer(buf), 1 <= x < 10 ? lng-4 : lng)
return bytestring(pointer(buf), 1 <= x < 10 || x == 0 ? lng - 4 : lng)
end

print(io::IO, b::BigFloat) = print(io, string(b))
Expand Down

0 comments on commit c09aebf

Please sign in to comment.