using System; using System.Numerics; // ulong is unsigned 64-bit: 2^64 - 1 is exactly its largest value. ulong moves = ulong.MaxValue; Console.WriteLine($"ulong: {moves}"); // By default, arithmetic that overflows wraps round silently... ulong wrapped = moves + 1; Console.WriteLine($"wrapped: {wrapped}"); // ...unless you ask for it to be checked. try { ulong next = checked(moves + 1); Console.WriteLine($"checked: {next}"); } catch (OverflowException) { Console.WriteLine("checked: OverflowException"); } // UInt128, since .NET 7, is twice as wide: its maximum is the 128-disk count. Console.WriteLine($"UInt128: {UInt128.MaxValue}"); // BigInteger has no ceiling at all. Console.WriteLine($"BigInteger: {BigInteger.Pow(2, 64) - 1}");