BigIntegers: Using J# Redistributable Classes

Standard .NET Framework 1.1 classes do not directly provide support for arbitrary precision numbers. However, the J# redistributable provides legacy support for Java 1.1.4 classes, which are represented in the vjslib.dll assembly. You can easily browse the various namespaces in this assembly using ildasm vjslib.dll and discover some useful functionality not available in standard .NET 1.1 classes.

For example, the following simple code shows how to use the arbitrary precision BigInteger class in C# to display a binary representation of any decimal or hex number:

using System;
using java.math;

class BignumBits {
 public static void Main(String[] args) 
	BigInteger big = null;
	  String bnum = args[0].Trim().ToLower();
		big = new BigInteger(bnum.TrimEnd('h'), 16);	//base 16 input
		big = new BigInteger(bnum);			//base 10 input
	  Console.WriteLine("Invalid number, or no number provided");
	Console.WriteLine("\nBig Integer in binary form:\n{0}", big.toString(2)) ;

To compile using the basic .NET Framework SDK 1.1, invoke the following command:
  csc.exe /r:C:\WINNT\Microsoft.NET\Framework\v1.1.4322\vjslib.dll BignumBits.cs
where the J# assembly is explicitly referenced.
Sample output for a typical 335 decimal digit number shows a very exciting bit pattern:
Bit dump of 335 digit number

Michel I. Gallant