-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
32 lines (30 loc) · 1.38 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HugeNumbers
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Using a list of bits representing powers of -2 one can represent any number in base(-2):");
for(long number = -23;number <= 23;++number)
{
HugeNumber n = new HugeNumber(number);
Console.WriteLine($"Number: {number} in base(-2): {n}");
}
Console.WriteLine("Bits are ordered from low to high.\n This allows the representation of large numbers with NO ROLL OVER or sign bit.");
HugeNumber max_long = new HugeNumber(long.MaxValue);
Console.WriteLine($"Max long:\n Original: {int.MaxValue} ({max_long.ToString()})\n Negated: {max_long.Negate()} ({max_long.Negate().ToLong()}) Length {max_long.Count}");
HugeNumber min_long = new HugeNumber(long.MinValue);
Console.WriteLine($"Min long\n: Original: {int.MinValue} ({min_long.ToString()})\n Negated: {min_long.Negate()} ({min_long.Negate().ToLong()}) Length {min_long.Count}");
Console.WriteLine("Math can be done on the bit strings:");
Console.WriteLine($"long.MaxValue + long.MaxValue = {max_long+max_long} base(-2)");
HugeNumber diff = max_long + min_long;
Console.WriteLine($"long.MaxValue + long.MinValue = {diff} base(-2) ({diff.ToLong()} in base 10)");
Console.ReadLine();
}
}
}