BigInteger Properties
The BigInteger type exposes the following members.
| Name | Description | |
|---|---|---|
|
IsEven | Indicates whether the value of the current BigInteger object is an even number. |
|
IsOne | Indicates whether the value of the current BigInteger object is BigInteger.One. |
|
IsPowerOfTwo | Indicates whether the value of the current BigInteger object is a power of two. |
|
IsZero | Indicates whether the value of the current BigInteger object is BigInteger.Zero. |
|
MinusOne | Gets a value that represents the number negative one (-1). |
|
One | Gets a value that represents the number one (1). |
|
Sign | Gets a number that indicates the sign (negative, positive, or zero) of the current BigInteger object. |
|
Zero | Gets a value that represents the number 0 (zero). |
Sample of Static Properties using PowerShell
<#
.SYNOPSIS
This script displays statoc properties of a BigInteger
.DESCRIPTION
This script demonstrates the static properties of the BigInteger class.
.NOTES
File Name : Get-BigIntegerStaticProperties.ps1
Author : Thomas Lee - tfl@psp.co.uk
Requires : PowerShell Version 2.0
.NET Framework 4
.LINK
This script posted to:
http://www.pshscripts.blogspot.com
MSDN Sample posted at:
http://msdn.microsoft.com/en-us/library/system.numerics.biginteger_properties.aspx
.EXAMPLE
PSH [C:\foo]: .\Get-BigIntegerStaticProperties.ps1
MinusOne: -1
Zero : 0
One : 1
#>
# Add the .NET Version 4 System.Numerics namespace
$return = [System.Reflection.Assembly]::LoadWithPartialName("System.Numerics")
# Display the static properties of BigIntegerClass
" MinusOne: {0}" -f [System.Numerics.BigInteger]::MinusOne
" Zero : {0}" -f [System.Numerics.BigInteger]::Zero
" One : {0}" -f [System.Numerics.BigInteger]::One
- 8/2/2010
- Thomas Lee
Sample using PowerShell
<#
.SYNOPSIS
This script displays dynamic properties of a BigInteger
.DESCRIPTION
This script demonstates the properties on an instance of BigInteger
.NOTES
File Name : Get-BigIntegerProperties.ps1
Author : Thomas Lee - tfl@psp.co.uk
Requires : PowerShell Version 2.0
.NET Framework 4
.LINK
This script posted to:
http://www.pshscripts.blogspot.com
MSDN Sample posted at:
http://msdn.microsoft.com/en-us/library/system.numerics.biginteger_properties.aspx
.EXAMPLE
PSH [c:\foo]: .\Get-BigIntegerProperties.ps1
Big Integer from 4096:
IsPowerOfTwo : True
IsZero : False
IsOne : False
IsEven : True
Sign : 1
#>
# Add the .NET Version 4 System.Numerics.Dll
Add-Type -Path "C:\Windows\Microsoft.NET\Framework\v4.0.30319\System.Numerics.dll"
# Create a big integer then display it's key properties
$BigInt = New-object System.Numerics.BigInteger 4096
"Big Integer from 4096:"
$BigIntFromDouble | fl *
- 8/2/2010
- Thomas Lee
- 8/2/2010
- Thomas Lee