extend CanonicalByteArray support for numbers
java.mathBigDecimal, java.mathBigInteger, clojure.lang.BigInt
This commit is contained in:
parent
ff1d4b7f12
commit
284dcc0eae
@ -1,6 +1,7 @@
|
|||||||
(ns valuehash.impl
|
(ns valuehash.impl
|
||||||
"Simple implementation based on plain byte arrays"
|
"Simple implementation based on plain byte arrays"
|
||||||
(:import [java.util UUID Date]))
|
(:import [java.util UUID Date]
|
||||||
|
[java.math BigDecimal BigInteger]))
|
||||||
|
|
||||||
(defprotocol CanonicalByteArray
|
(defprotocol CanonicalByteArray
|
||||||
"An object that can be converted to a canonical byte array, with value
|
"An object that can be converted to a canonical byte array, with value
|
||||||
@ -64,6 +65,12 @@
|
|||||||
(to-byte-array [this] (long->bytes (Double/doubleToLongBits this)))
|
(to-byte-array [this] (long->bytes (Double/doubleToLongBits this)))
|
||||||
clojure.lang.Ratio
|
clojure.lang.Ratio
|
||||||
(to-byte-array [this] (long->bytes (Double/doubleToLongBits (double this))))
|
(to-byte-array [this] (long->bytes (Double/doubleToLongBits (double this))))
|
||||||
|
clojure.lang.BigInt
|
||||||
|
(to-byte-array [this] (long->bytes (Double/doubleToLongBits (double this))))
|
||||||
|
BigInteger
|
||||||
|
(to-byte-array [this] (long->bytes (Double/doubleToLongBits (double this))))
|
||||||
|
BigDecimal
|
||||||
|
(to-byte-array [this] (long->bytes (Double/doubleToLongBits (double this))))
|
||||||
Boolean
|
Boolean
|
||||||
(to-byte-array [this] (byte-array 1 (if this (byte 1) (byte 0))))
|
(to-byte-array [this] (byte-array 1 (if this (byte 1) (byte 0))))
|
||||||
Character
|
Character
|
||||||
|
Loading…
x
Reference in New Issue
Block a user