Sunday 1 August 2010

Get-BigIntegerProperties.ps1


  1. <# 
  2. .SYNOPSIS 
  3.     This script displays dynamic properties of a BigInteger  
  4. .DESCRIPTION 
  5.     This script demonstates the properties on an instance of BigInteger 
  6. .NOTES 
  7.     File Name  : Get-BigIntegerProperties.ps1 
  8.     Author     : Thomas Lee - tfl@psp.co.uk 
  9.     Requires   : PowerShell Version 2.0 
  10.                  .NET Framework 4    
  11. .LINK 
  12.     This script posted to: 
  13.         http://www.pshscripts.blogspot.com 
  14.     MSDN Sample posted at: 
  15.         http://msdn.microsoft.com/en-us/library/system.numerics.biginteger_properties.aspx 
  16. .EXAMPLE 
  17.     PSH [c:\foo]: .\Get-BigIntegerProperties.ps1 
  18.     Big Integer from 4096: 
  19.  
  20.     IsPowerOfTwo : True 
  21.     IsZero       : False 
  22.     IsOne        : False 
  23.     IsEven       : True 
  24.     Sign         : 1 
  25. #> 
  26.  
  27. # Add the .NET Version 4 System.Numerics.DLL 
  28. Add-Type -Path "C:\Windows\Microsoft.NET\Framework\v4.0.30319\System.Numerics.dll" 
  29.  
  30. # Create a big integer then display it's key properties 
  31. $BigInt = New-object System.Numerics.BigInteger 4096 
  32. "Big Integer from 4096:" 
  33. $BigInt | fl * 

2 comments:

RT said...

Shouldn't $BigIntFromDouble just be $BigInt ?
Otherwise the script won't work.

Thomas Lee said...

Good catch RT - fixed