Thursday, October 29, 2009

Using F# BigInt in PowerShell

Occasionally I have the need to utilize large precise numbers within PowerShell. Unfortunately, the native data types that we can use are limited in their precision.
  • Float: 7 digits
  • Double: 16 digits
  • Decimal: 29 digits

I have been researching F# and came across a data type called BigInt. I now knew that I could go back to PowerShell and take advantage of this type.

The process to do so is straight forward:
First add a reference to the FSharp.Core assembly

Add-Type -Path 'C:\Program Files (x86)\FSharp-\bin\fSharp.Core.dll'

Now you do things like:
PS C:> [Microsoft.FSharp.Math.BigInt]::Pow(17,71).toString()
PS C:>2300771122759378216336589429524308

So if you are a fan of you now have another tool you can utilize.


1 comment:

wangwei said...

Thank you so much for this post, it was very insightful! I have found a direct conversion software,
Blu-ray dvd ripper helps you create Blu-ray discs from various videos for playback on any Blu-ray players. With this software, you can easily burn your videos to Blu-ray discs and AVCHD DVDs .
More info you can visit:
More Related Products : * blu-ray dvd ripper * blu-ray ripper * blu-ray to avi * blu-ray to mpeg * blu-ray dvd converter