Skip to content

Commit c85db12

Browse files
authored
Add overloads for fld and cld (#581)
* Add fld and cld * Add new tests * Increment patch number * Match method defined in base * Revert "Match method defined in base" This reverts commit d676c2c.
1 parent eed0ff3 commit c85db12

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "ForwardDiff"
22
uuid = "f6369f11-7733-5829-9624-2563aa707210"
3-
version = "0.10.25"
3+
version = "0.10.26"
44

55
[deps]
66
CommonSubexpressions = "bbf7d656-a473-5ed7-a52c-81e309532950"

src/dual.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,10 @@ Base.trunc(d::Dual) = trunc(value(d))
284284
Base.round(::Type{R}, d::Dual) where {R<:Real} = round(R, value(d))
285285
Base.round(d::Dual) = round(value(d))
286286

287+
Base.fld(x::Dual, y::Dual) = fld(value(x), value(y))
288+
289+
Base.cld(x::Dual, y::Dual) = cld(value(x), value(y))
290+
287291
if VERSION v"1.4"
288292
Base.div(x::Dual, y::Dual, r::RoundingMode) = div(value(x), value(y), r)
289293
else

test/DualTest.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,14 @@ for N in (0,3), M in (0,4), V in (Int, Float32)
137137
@test round(FDNUM2) === round(PRIMAL2)
138138
@test round(NESTED_FDNUM) === round(PRIMAL)
139139

140+
@test fld(FDNUM, FDNUM2) === fld(PRIMAL, PRIMAL2)
141+
@test fld(FDNUM, PRIMAL2) === fld(PRIMAL, PRIMAL2)
142+
@test fld(PRIMAL, FDNUM2) === fld(PRIMAL, PRIMAL2)
143+
144+
@test cld(FDNUM, FDNUM2) === cld(PRIMAL, PRIMAL2)
145+
@test cld(FDNUM, PRIMAL2) === cld(PRIMAL, PRIMAL2)
146+
@test cld(PRIMAL, FDNUM2) === cld(PRIMAL, PRIMAL2)
147+
140148
@test div(FDNUM, FDNUM2) === div(PRIMAL, PRIMAL2)
141149
@test div(FDNUM, PRIMAL2) === div(PRIMAL, PRIMAL2)
142150
@test div(PRIMAL, FDNUM2) === div(PRIMAL, PRIMAL2)

0 commit comments

Comments
 (0)