4.10. New Types
Now that the lowdown changes are out of the way, lets look at some of the new types in .NET 4.0 and modifications to existing classes and methods.
4.10.1. BigInteger
Working with really big numbers in .NET can get a bit strange. For example, try the following example (without advanced options such as overflow checking), and you might be surprised at the result you get:
int a = 2000000000; Console.WriteLine(a * 2); Console.ReadKey();
Surely the result is 4000000000? Running this code will give you the following answer:
−294967296
NOTE
VB.NET won't even let you compile the equivalent.
This issue occurs due to how this type of integer is represented in binary and the overflow that occurs. After the multiplication, the number gets ...
Get Introducing .NET 4.0: with Visual Studio 2010 now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.