<p>Is there a way to initialize an integer greater than 64 bits using the big package? The NewInt function takes an int64 as a parameter... It seems strange to me that you can't initialize an int greater than 64 bits, but a big.Int type can hold integers greater than 64 bits</p>
<hr/>**评论:**<br/><br/>knotdjb: <pre><p>You can use <a href="https://golang.org/pkg/math/big/#Int.SetString" rel="nofollow">SetString</a>, you will pay the penalty for the decode.</p></pre>Palm7: <pre><p>Ah man I must have missed this function. I've got it working now. Thanks a lot</p></pre>Bake_Jailey: <pre><p>I bet you could also get away with something like a combination of <code>NewInt(...)</code> and <code>Lsh(64).Or(...)</code>, which may be faster than the decode cost, but I haven't tested it, and you may not care about the performance implications (or you don't need this at all and you're just curious :P).</p></pre>
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889
0 回复
- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码`
- 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传