[英]Clojure equivalent of python int.from_bytes(byteorder='big')
The Python built in method int.from_bytes()
returns the integer represented by the given array of bytes. Python内置方法
int.from_bytes()
返回由给定字节数组表示的整数。 I wanted know the Clojure equivalent of such method or similar methods in Clojure. 我想知道Clojure中与此类方法或类似方法相似的Clojure。
You could use java's java's BigInteger directly: 您可以直接使用Java的Java的BigInteger :
(BigInteger. (byte-array [1 2 3]))
=> 66051
Since clojure natively supports big numbers, you could use it seamlessly with clojure's arithmetics: 由于clojure本机支持大数,因此您可以与clojure的算法无缝地使用它:
(def b (BigInteger. (byte-array [1 2 3])))
(+ b 23)
=> 66074N
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.