Skip to content

Commit d080469

Browse files
committed
WIP: add div/mul for TwicePrecision?
1 parent 925958b commit d080469

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/search.jl

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,20 @@ function unsafe_searchsortednearest(vec::Range, x)
2424
return idx
2525
end
2626

27+
# Dekker div2
28+
import Base: TwicePrecision, splitprec
29+
function Base.inv(y::TwicePrecision)
30+
c = inv(y.hi)
31+
chh, clo = splitprec(c)
32+
u = TwicePrecision(chi, clo) * y.hi
33+
cc = (((1 - u.hi) - u.lo) - c*y.lo)/y.hi
34+
TwicePrecision(c, cc)
35+
end
36+
function *{T}(x::TwicePrecision{T}, y::TwicePrecision{T})
37+
c = TwicePrecision(splitprec(x.hi)...) * y.hi
38+
cc = (x.hi * y.lo + x.lo* y.hi) + c.lo
39+
TwicePrecision(c.hi, cc)
40+
end
2741

2842
function nsteps(x, step)
2943
offset = floor(Int, abs(x / step))

0 commit comments

Comments
 (0)