gpt4 book ai didi

c# - 保持数字长于 64 位长

转载 作者:太空狗 更新时间:2023-10-29 22:04:28 24 4
gpt4 key购买 nike

我需要保留比 long 或 Int64 长的程序编号。因为如果我使用 long,它将只返回 0。

最佳答案

您可以使用 BigInteger在 .Net 4.0 中

The BigInteger type is an immutable type that represents an arbitrarily large integer whose value in theory has no upper or lower bounds. The members of the BigInteger type closely parallel those of other integral types (the Byte, Int16, Int32, Int64, SByte, UInt16, UInt32, and UInt64 types). This type differs from the other integral types in the .NET Framework, which have a range indicated by their MinValue and MaxValue properties.

如果您没有迁移到 .Net 4 的奢侈,那么您可以使用一个名为 IntX 的开源项目来帮助您。 .

IntX is an arbitrary precision integers library written in pure C# 2.0 with fast - about O(N * log N) - multiplication/division algorithms implementation. It provides all the basic arithmetic operations on integers, comparing, bitwise shifting etc. It also allows parsing numbers in different bases and converting them to string, also in any base. The advantage of this library is fast multiplication, division and from base/to base conversion algorithms - all the fast versions of the algorithms are based on fast multiplication of big integers using Fast Hartley Transform which runs for O(N * log N * log log N) time instead of classic O(N^2).

关于c# - 保持数字长于 64 位长,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18975044/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com