Windows PowerShell で、型の最小値と最大値を取得する方法について説明します。
int 型の最小値と最大値を取得
(char 型以外の型はこの方法で取得できます。)
[int]::MinValue [int]::MaxValue
char 型の最小値と最大値を取得
このサンプルでは、MinValue, MaxValue メソッドの戻り値を int 型にキャストしています。理由はこれらのメソッドの戻り値が char 型のためです。
[int][char]::MinValue [int][char]::MaxValue
全ての型の最小値と最大値のまとめ
|
型の別名 |
型名 |
最小値 |
最大値 |
| sbyte | System.SByte |
-128 |
127 |
| byte | System.Byte |
0 |
255 |
| System.Int16 |
-32768 |
32767 |
|
| System.UInt16 |
0 |
65535 |
|
| int | System.Int32 |
-2147483648 |
2147483647 |
| System.UInt32 |
0 |
4294967295 |
|
| long | System.Int64 |
-9223372036854775808 |
9223372036854775807 |
| System.UInt64 |
0 |
18446744073709551615 |
|
| char | System.Char |
0 |
65535 |
| float | System.Single |
-3.402823E+38 |
3.402823E+38 |
| double | System.Double |
-1.79769313486232E+308 |
1.79769313486232E+308 |
| bool | System.Boolean | (なし) | (なし) |
| decimal | System.Decimal |
-79228162514264337593543950335 |
79228162514264337593543950335 |
| string | System.String | (なし) | (なし) |