How to do it

The input will be taken as a string. The output would also be string, but the octal, hexadecimal and binary representations. We will use a .NET accelerator for this.

  1. Open a new PowerShell file and type the following:
$InputString = Read-Host "Enter an integer"

Write-Host "Octal representation: " -NoNewline
Write-Host "$([Convert]::ToString($InputString, 8))"

Write-Host "Hexadecimal representation: " -NoNewline
Write-Host "$([Convert]::ToString($InputString, 16))"

Write-Host "Binary representation: " -NoNewline
Write-Host "$([Convert]::ToString($InputString, 2))"
  1. Run the script and enter an integer to get the octal, hexadecimal and binary representations of it.

Do not forget to try negative numbers as well.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.140.242.165