Clojure unsigned 64 bit integers

How to identify unsigned long in Clojure? (Or are there arbitrary dimensional numbers in the standard library, for example, some BigInt or BigNum?)

I would use it only in bitwise operations, so technically the numerical value represented by binary data is not so important, but I would still like numbers> 2 63 to display as positive integers when I have printlnthem.

+4
source share
1 answer

I would suggest just writing a custom function that converts yours longto a string with the corresponding unsigned representation.

Sort of:

(defn long-str [x] 
     (if (> x 0) 
       (str x)
       (str (+ (bigint x) 18446744073709551616N))))

(long-str -1)
=> "18446744073709551615"
+1
source

Source: https://habr.com/ru/post/1525918/


All Articles