Reputation: 16615
How do I define an unsigned long
in Clojure? (Or are there arbitrary size integers in the standard library, e.g. some sort of BigInt or BigNum?)
I'd only use it in bitwise operations, so technically the numeric value represented by the binary data is not so important, but I'd still like numbers >263 to be displayed as positive integers when I println
them.
Upvotes: 4
Views: 775
Reputation: 106351
I'd suggest just writing a custom function that converts your long
into a String with the appropriate unsigned representation.
Something like:
(defn long-str [x]
(if (> x 0)
(str x)
(str (+ (bigint x) 18446744073709551616N))))
(long-str -1)
=> "18446744073709551615"
Upvotes: 1