The Python built in method int.from_bytes()
returns the integer represented by the given array of bytes. I wanted know the Clojure equivalent of such method or similar methods in Clojure.
You could use java's java's BigInteger directly:
(BigInteger. (byte-array [1 2 3]))
=> 66051
Since clojure natively supports big numbers, you could use it seamlessly with clojure's arithmetics:
(def b (BigInteger. (byte-array [1 2 3])))
(+ b 23)
=> 66074N
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.