- <#
- .SYNOPSIS
- This script creates and displays a BigInteger.
- .DESCRIPTION
- This script is a rewrite of an MSDN sample.
- .NOTES
- File Name : New-BigInteger.ps1
- Author : Thomas Lee - tfl@psp.co.uk
- Requires : PowerShell Version 2.0
- .NET Framework 4
- .LINK
- This script posted to:
- http://pshscripts.blogspot.com/2010/07/new-bigintegerps1.html
- MSDN Sample posted at:
- http://msdn.microsoft.com/en-us/library/system.numerics.biginteger.aspx
- .EXAMPLE
- PSH [c:\foo]: .\Get-BigInteger.ps1
- Big Integer from 179032.6541:
- 179,032
- Big Integer from 1234934157136952:
- 1,234,934,157,136,952
- #>
- # Add the .NET Version 4 System.Numerics.DLL
- Add-Type -Path "C:\Windows\Microsoft.NET\Framework\v4.0.30319\System.Numerics.dll"
- # Create first big integer then display it nicely
- $BigIntFromDouble = New-Object System.Numerics.BigInteger 179032.6541
- "Big Integer from 179032.6541:"
- $BigIntFromDouble.ToString("N0")
- #Create second big integer then display it nicely
- $BigIntFromInt64 = New-object System.Numerics.BigInteger 1234934157136952
- "Big Integer from 1234934157136952:"
- $Bigintfromint64.tostring("N0")
This blog contains PowerShell scripts, more PowerShell scripts and still more PowerShell scripts. Occasionally you may see some organisational posts.
Saturday, 31 July 2010
New-BigInteger.ps1
Labels:
.Net 4.0,
BigInteger,
powershell,
PowerShell scripts,
System.Numerics
Subscribe to:
Post Comments (Atom)
2 comments:
Could not load file or assembly 'file:///C:\Windows\Microsoft.NET\Framework\v4.0.30319\System.Numerics.dll' or one of its dependencies.
This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.
You are most probably using PowerShell V2 with the standard .NET 2.0 framework. The class being used here is new in the .NET Framework 4.0, thus is not normally available.
You can setup PowerShell to bind to .NET 4.0, in which case you'll find this assembly, alternatively, use the beta of PowerShell V3.
Post a Comment