We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 3c9285f commit 5b84e7eCopy full SHA for 5b84e7e
src/FixedPointDecimals.jl
@@ -32,7 +32,7 @@ using Compat
32
import Base: reinterpret, zero, one, abs, sign, ==, <, <=, +, -, /, *, div, rem, divrem,
33
fld, mod, fldmod, fld1, mod1, fldmod1, isinteger, typemin, typemax,
34
realmin, realmax, print, show, string, convert, parse, promote_rule, min, max,
35
- trunc, round, floor, ceil, eps, float, widemul
+ trunc, round, floor, ceil, eps, float, widemul, decompose
36
37
const BitInteger = Union{Int8, UInt8, Int16, UInt16, Int32, UInt32, Int64,
38
UInt64, Int128, UInt128}
@@ -475,6 +475,7 @@ coefficient(::Type{FD{T, f}}) where {T, f} = T(10)^f
475
coefficient(fd::FD{T, f}) where {T, f} = coefficient(FD{T, f})
476
value(fd::FD) = fd.i
477
478
-Base.hash(fd::FD{T, f}, h::UInt) where {T, f} = Base.hash(BigFloat(fd), h)
+# for generic hashing
479
+decompose(fd::FD) = decompose(Rational(fd))
480
481
end
test/runtests.jl
@@ -947,6 +947,8 @@ end
947
@test hash(fd1) == hash(fd2)
948
@test hash(fd1) != hash(fd3)
949
@test hash(fd1) != hash(fd1.i)
950
+ @test hash(FD2(1//10)) == hash(1//10)
951
+ @test hash(FD2(1//10)) ≠ hash(0.1)
952
953
954
0 commit comments