Golang大整数到二进制字符串 [英] Golang Big Integers to Binary String
本文介绍了Golang大整数到二进制字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我看到将golang的big int(数学/大包)转换为字符串很简单,但是有什么简单的方法可以将big int转换为二进制字符串?
I see it's simple to convert golang's big int (math/big package) to a string, but is there any straightforward way of converting a big int to a binary string?
推荐答案
应该像这样简单:
i := big.NewInt(2014)
s := fmt.Sprintf("%b", i) // 11111011110
fmt.Println(s)
希望这就是您想要的.
这篇关于Golang大整数到二进制字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文