Skip to content

Commit 5699c4b

Browse files
authored
Merge pull request #57 from JuliaIO/revert-56-spj/round
Revert "Update calls to round, change signif to round"
2 parents 531efe6 + 124e641 commit 5699c4b

File tree

2 files changed

+5
-35
lines changed

2 files changed

+5
-35
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22

33
This package offers Python-style general formatting and c-style numerical formatting (for speed).
44

5-
[![Formatting](http://pkg.julialang.org/badges/Formatting_0.6.svg)](http://pkg.julialang.org/?pkg=Formatting&ver=0.6)
6-
[![Formatting](http://pkg.julialang.org/badges/Formatting_0.7.svg)](http://pkg.julialang.org/?pkg=Formatting&ver=0.7)
5+
[![Build Status](https://travis-ci.org/JuliaIO/Formatting.jl.svg?branch=master)](https://travis-ci.org/JuliaIO/Formatting.jl)
6+
[![Formatting](http://pkg.julialang.org/badges/Formatting_0.4.svg)](http://pkg.julialang.org/?pkg=Formatting&ver=0.4)
7+
[![Formatting](http://pkg.julialang.org/badges/Formatting_0.5.svg)](http://pkg.julialang.org/?pkg=Formatting&ver=0.5)
78

89
---------------
910

src/fmtcore.jl

Lines changed: 2 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,7 @@ end
171171

172172
function _pfmt_f(out::IO, fs::FormatSpec, x::AbstractFloat)
173173
# separate sign, integer, and decimal part
174-
rax = (@static VERSION < v"0.7.0-DEV.4804" ? round(abs(x), fs.prec) :
175-
round(abs(x); digits=fs.prec))
174+
rax = round(abs(x), fs.prec)
176175
sch = _signchar(x, fs.sign)
177176
intv = trunc(Integer, rax)
178177
decv = rax - intv
@@ -219,36 +218,6 @@ function _pfmt_floate(out::IO, sch::Char, zs::Integer, u::Real, prec::Int, e::In
219218
end
220219

221220

222-
# Pull in definition of signif from v0.6.2 base, since it is currently broken for
223-
# BigFloat and DecFP (at least) on master
224-
225-
@static if VERSION >= v"0.7.0-DEV.4804"
226-
# adapted from Matlab File Exchange roundsd: http://www.mathworks.com/matlabcentral/fileexchange/26212
227-
# for round, og is the power of 10 relative to the decimal point
228-
# for signif, og is the absolute power of 10
229-
# digits and base must be integers, x must be convertable to float
230-
231-
function signif(x::Real, digits::Integer, base::Integer=10)
232-
digits < 1 && throw(DomainError())
233-
234-
x = float(x)
235-
(x == 0 || !isfinite(x)) && return x
236-
if base == 10
237-
e = floor(log10(abs(x)) - digits + 1.)
238-
og = oftype(x, exp10(abs(e)))
239-
elseif base == 2
240-
e = exponent(abs(x)) - digits + 1.
241-
og = oftype(x, exp2(abs(e)))
242-
else
243-
e = floor(log(base, abs(x)) - digits + 1.)
244-
og = oftype(x, float(base) ^ abs(e))
245-
end
246-
# for numeric stability
247-
r = e >= 0 ? round(x/og)*og : round(x*og)/og
248-
isfinite(r) ? r : x
249-
end
250-
end
251-
252221
function _pfmt_e(out::IO, fs::FormatSpec, x::AbstractFloat)
253222
# extract sign, significand, and exponent
254223
ax = abs(x)
@@ -257,7 +226,7 @@ function _pfmt_e(out::IO, fs::FormatSpec, x::AbstractFloat)
257226
e = 0
258227
u = zero(x)
259228
else
260-
rax = signif(ax, fs.prec + 1) # round(ax; sigdigits = fs.prec + 1)
229+
rax = signif(ax, fs.prec + 1)
261230
e = floor(Integer, log10(rax)) # exponent
262231
u = rax * exp10(-e) # significand
263232
end

0 commit comments

Comments
 (0)