Large numbers and Data Type
If I wanted to add two natural numbers together that are more then 1开发者_如何学Python50 digits each what data type would I need to use?
Edit: using .Net 3.5
If you're using .NET 4.0, the obvious solution is to use BigInteger
, which is designed to handle arbitrary-size integers.
For .NET 3.5 or earlier, the IntX library looks like a good option - seems to be well optimised. Or if you want something a bit lighter-weight/simpler, but still quite complete, this BigInteger class posted on CodeProject looks decent.
3.5? Try using IntX. (Or if you're just adding, you can roll your own with arrays of bytes, etc.)
I dont think any datatype can work on that much long numbers. You have to make use of logarithmic functions to do that.
精彩评论