Showing posts with label BigInteger. Show all posts
Showing posts with label BigInteger. Show all posts

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 * 

Saturday, 31 July 2010

New-BigInteger.ps1

  1. <# 
  2. .SYNOPSIS 
  3.     This script creates and displays a BigInteger.  
  4. .DESCRIPTION 
  5.     This script is a rewrite of an MSDN sample. 
  6. .NOTES 
  7.     File Name  : New-BigInteger.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://pshscripts.blogspot.com/2010/07/new-bigintegerps1.html 
  14.     MSDN Sample posted at: 
  15.         http://msdn.microsoft.com/en-us/library/system.numerics.biginteger.aspx  
  16. .EXAMPLE 
  17.     PSH [c:\foo]: .\Get-BigInteger.ps1 
  18.     Big Integer from 179032.6541: 
  19.     179,032 
  20.     Big Integer from 1234934157136952: 
  21.     1,234,934,157,136,952 
  22. #> 
  23.  
  24. # Add the .NET Version 4 System.Numerics.DLL 
  25. Add-Type -Path "C:\Windows\Microsoft.NET\Framework\v4.0.30319\System.Numerics.dll" 
  26.  
  27. # Create first big integer then display it nicely 
  28. $BigIntFromDouble = New-Object System.Numerics.BigInteger 179032.6541 
  29. "Big Integer from 179032.6541:" 
  30. $BigIntFromDouble.ToString("N0"
  31.  
  32. #Create second big integer then display it nicely 
  33. $BigIntFromInt64 = New-object System.Numerics.BigInteger 1234934157136952 
  34. "Big Integer from 1234934157136952:" 
  35. $Bigintfromint64.tostring("N0"