0

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.

1 Answer 1

2

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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.