Pam*_*Pam 3 c# vb.net biginteger bitarray
我正在使用的BigInteger类型System.Numerics.
例如:
Dim Mult17 As BigInteger = BigInteger.Parse("1453453452342347")
Run Code Online (Sandbox Code Playgroud)
问题:
给定a BigInteger,如何将其转换为BitArray?(显然我希望BitArray保存二进制10101 ...表示存储在BigInteger变量中的数字,我希望可以选择以一种方式或相反的方式存储它.)
我还需要从a BitArray回到a BigInteger.
请注意,没有迹象表明:我只处理正整数.VB.NET或C#示例都没问题.谢谢.
好吧,看起来你可以使用.ToByteArray()将BigInteger带到byte [] .
幸运的是,BitArray将byte []作为构造函数参数.
要向后,BitArray到byte [],使用此扩展,然后在构造函数中传入BigInteger
它看起来应该有效.完全披露,我懒得测试这个.
| 归档时间: |
|
| 查看次数: |
898 次 |
| 最近记录: |