I'm trying to work through the problems on projecteuler.net but I keep running into a couple of problems.
The first is a question of storing large quanities of elements in a List<t>
. I keep getting OutOfMemoryException's when storing large quantities in the list.
Now I admit I might not be doing these things in the best way but, is there some way of defining how much memory the app can consume?
It usually crashes when I get abour 100,000,000 elements :S
Secondly, some of the questions require the addition of massive numbers. I use ulong data type where I think the number is going to get super big, but I still manage to wrap past the largest supported int and get into negative numbers.
Do you have any tips for working with incredibly large numbers?
Power notation is a method to express numbers that are very large or very small. For eg- 1000000000000 can be written as 1012 and 0.00000026 can be written as 2.6 × 10-7. Scientific notation is a similar method to express numbers in the form of nth power of 10. For eg; 1.67 × 107.
Representation You might use an array to hold all the digits of large numbers. A more efficient way would be to use an array of 32 bit unsigned integers and store "32 bit chunks" of the large number. You can think of these chunks as individual digits in a number system with 2^32 distinct digits or characters.
CSharp Online Training int num1, num2, num3; // set the value of the three numbers num1 = 10; num2 = 20; num3 = 50; Now check the first number with the second number. If num1 > num2, then check num1 with num3. If num1 is greater than num3, that would mean the largest number is num1.
They are mostly used while calculating a country's population or while counting the money in a bank account. For example, 1 million and 1 billion are considered as large numbers.
Consider System.Numerics.BigInteger.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With