Created
October 28, 2015 07:42
-
-
Save n-fukuju/306fb73c7947a136186a to your computer and use it in GitHub Desktop.
PowerShellで基数の変換の覚書
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 16進数文字列で出力 | |
(100).ToString("X") | |
# => 64 | |
# 16進数から10進数文字列に変換 | |
[Convert]::ToString(0x64, 10) | |
# => 100 | |
[Convert]::ToString("0x64", 10) | |
# => 100 | |
# 16進数から2進数文字列に変換 | |
[Convert]::ToString(0x64, 2) | |
# => 1100100 | |
[Convert]::ToString("0x64", 2) | |
# => 1100100 | |
# 他の基数変換のパターンも、[Convert]::ToString を使えばよい。 | |
# プレフィックスなしの16進数文字列をintに変換 | |
[Convert]::ToInt32("64", 16) | |
# => 100 | |
# 同様に、2進数文字列からintに変換 | |
[Convert]::ToInt32("1100100", 2) | |
# => 100 | |
# バイトの配列を単純に整形 | |
[BitConverter]::ToString(@(0xFF,255,0)) | |
# => FF-FF-00 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment