Friday, July 3, 2009

C# BigInt Using The F# Libraries

Download and install the F# September 2008 CTP.
This will add the necessary assembly's needed to access the F# BigInt class from C#.

Then just add a reference to the FSharp.Core assembly:

If you can't find the assembly try restarting Visual Studio and/or reinstalling the F# runtime.
Dont forget to add an "using Microsoft.FSharp.Math" statement like done below.

using System;
using Microsoft.FSharp.Math;

namespace BigIntExample
class Program
static void Main(string[] args)
//make a BigInt with the max value of a long
BigInt x = new BigInt(long.MaxValue);

//same but with an integer
BigInt y = new BigInt(int.MaxValue);

//then do some big math hoho
var sum = x * y;


If you're interested in learning more about F# check out
the F# - Microsoft Research site.
Also the F# libraries will be included as a standard in the
new Visual Studio 2010.