Initialize an integer greater than 64 bits using math/big package?

blov · · 378 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<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&#39;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&#39;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&#39;t tested it, and you may not care about the performance implications (or you don&#39;t need this at all and you&#39;re just curious :P).</p></pre>

入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

378 次点击  
加入收藏 微博
0 回复
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传