NumberingSystemConversion.psm1
#region Convert-DecimalToBinary Function Convert-DecimalToBinary { <# .SYNOPSIS Convert a value from decimal to binary .DESCRIPTION The Convert-DecimalToBinary cmdlet converts a value from decimal to binary .PARAMETER Decimal The value to convert .EXAMPLE Convert-DecimalToBinary 10 This cmdlet will convert the value 10 to binary #> Param ( [int[]]$Decimal ) foreach($i in $Decimal) { $binary = [convert]::ToString($i,2) $obj = New-Object psobject $obj | Add-Member -MemberType NoteProperty -Name Decimal -Value $i $obj | Add-Member -MemberType NoteProperty -Name Binary -Value $Binary Write-Output $obj } } #endregion #region Convert-BinaryToDecimal Function Convert-BinaryToDecimal { <# .SYNOPSIS Convert a value from binary to decimal .DESCRIPTION The Convert-BinaryToDecimal cmdlet converts a value from binary to decimal .PARAMETER Binary The value in binary format .EXAMPLE Convert-BinaryToDecimal 1000110 This cmdlet will convert the value 1000110 to decimal #> Param ( [string[]]$Binary ) foreach($b in $Binary) { $decimal = [convert]::ToInt32($b,2) $obj = New-Object psobject $obj | Add-Member -MemberType NoteProperty -Name Binary -Value $b $obj | Add-Member -MemberType NoteProperty -Name Decimal -Value $decimal Write-Output $obj } } #endregion #region Convert-DecimalToHexadecimal Function Convert-DecimalToHexadecimal { <# .SYNOPSIS Convert a value from decimal to hexadecimal .DESCRIPTION The Convert-DecimalToHexadecimal cmdlet converts a value from decimal to hexadecimal .PARAMETER Decimal The value in decimal format .EXAMPLE Convert-DecimalToHexadecimal 10 This cmdlet will convert the value 10 to hexadecimal #> Param ( [int[]]$Decimal ) foreach($i in $Decimal) { $hex = [convert]::ToString($i,16) $obj = New-Object psobject $obj | Add-Member -MemberType NoteProperty -Name Decimal -Value $i $obj | Add-Member -MemberType NoteProperty -Name Hexadecimal -Value $hex.ToUpper() Write-Output $obj } } #endregion #region Convert-HexadecimalToDecimal Function Convert-HexadecimalToDecimal { <# .SYNOPSIS Convert a value from hexadecimal to decimal .DESCRIPTION The Convert-HexadecimalToDecimal cmdlet converts a value from hexadecimal to decimal .PARAMETER Hexadecimal The value in hexadecimal format .EXAMPLE Convert-HexadecimalToDecimal 10AC3 This cmdlet will convert the value 10AC3 to decimal #> Param ( [string[]]$Hexadecimal ) foreach($h in $Hexadecimal) { $decimal = [convert]::ToInt32($h,16) $obj = New-Object psobject $obj | Add-Member -MemberType NoteProperty -Name Hexadecimal -Value $h.ToUpper() $obj | Add-Member -MemberType NoteProperty -Name Decimal -Value $decimal Write-Output $obj } } #endregion #region Convert-HexadecimalToBinary Function Convert-HexadecimalToBinary { <# .SYNOPSIS Convert a value from hexadecimal to binary .DESCRIPTION The Convert-HexadecimalToBinary cmdlet converts a value from hexadecimal to binary .PARAMETER Hexadecimal The value in hexadecimal format .EXAMPLE Convert-HexadecimalToBinary 10AC3 This cmdlet will convert the value 10AC3 to binary #> Param ( [string[]]$Hexadecimal ) foreach($h in $Hexadecimal) { $decimal = [convert]::ToInt32($h,16) $binary = Convert-DecimalToBinary $decimal $obj = New-Object psobject $obj | Add-Member -MemberType NoteProperty -Name Hexadecimal -Value $h.ToUpper() $obj | Add-Member -MemberType NoteProperty -Name Binary -Value $binary.Binary Write-Output $obj } } #endregion #region Convert-BInaryToHexadecimal Function Convert-BinaryToHexadecimal { <# .SYNOPSIS Convert a value from binary to hexadecimal .DESCRIPTION The Convert-BinaryToHexadecimal cmdlet converts a value from binary to hexadecimal .PARAMETER Binary The value in binary format .EXAMPLE Convert-BinaryToHexadecimal 1000110 This cmdlet will convert the value 1000110 to hexadecimal #> Param ( [string[]]$Binary ) foreach($b in $Binary) { $decimal = [convert]::ToInt32($b,2) $hex = Convert-DecimalToHexadecimal $decimal $obj = New-Object psobject $obj | Add-Member -MemberType NoteProperty -Name Binary -Value $b $obj | Add-Member -MemberType NoteProperty -Name Decimal -Value $hex.hexadecimal.toUpper() Write-Output $obj } } #endregion #region Convert-Binary Function Convert-Binary { <# .SYNOPSIS Convert a value from binary to other systems .DESCRIPTION The Convert-BinaryToHexadecimal cmdlet converts a value from binary to other systems .PARAMETER Binary The value in binary format .EXAMPLE Convert-BinaryToAll 1000110 This cmdlet will convert the value 1000110 to other systems #> Param ( [string[]]$Binary ) foreach($b in $Binary) { $decimal = [convert]::ToInt32($b,2) $hex = Convert-DecimalToHexadecimal $decimal $obj = New-Object psobject $obj | Add-Member -MemberType NoteProperty -Name Binary -Value $b $obj | Add-Member -MemberType NoteProperty -Name Decimal -Value $decimal $obj | Add-Member -MemberType NoteProperty -Name Hexadecimal -Value $hex.hexadecimal.toUpper() Write-Output $obj } } #endregion #region Convert-Hexadecimal Function Convert-Hexadecimal { <# .SYNOPSIS Convert a value from hexadecimal to other systems .DESCRIPTION The Convert-Hexadecimal cmdlet converts a value from hexadecimal to other systems .PARAMETER Hexadecimal The value in hexadecimal format .EXAMPLE Convert-Hexadecimal 10AC3 This cmdlet will convert the value 10AC3 to other systems #> Param ( [string[]]$Hexadecimal ) foreach($h in $Hexadecimal) { $decimal = [convert]::ToInt32($h,16) $binary = Convert-DecimalToBinary $decimal $obj = New-Object psobject $obj | Add-Member -MemberType NoteProperty -Name Binary -Value $binary.Binary $obj | Add-Member -MemberType NoteProperty -Name Decimal -Value $decimal $obj | Add-Member -MemberType NoteProperty -Name Hexadecimal -Value $h.ToUpper() Write-Output $obj } } #endregion #region Convert-Decimal Function Convert-Decimal { <# .SYNOPSIS Convert a value from decimal to other systems .DESCRIPTION The Convert-DecimalToHexadecimal cmdlet converts a value from decimal to other systems .PARAMETER Decimal The value in decimal format .EXAMPLE Convert-DecimalToHexadecimal 10 This cmdlet will convert the value 10 to other systems #> Param ( [int[]]$Decimal ) foreach($i in $Decimal) { $hex = [convert]::ToString($i,16) $binary = Convert-DecimalToBinary $i $obj = New-Object psobject $obj | Add-Member -MemberType NoteProperty -Name Decimal -Value $i $obj | Add-Member -MemberType NoteProperty -Name Binary -Value $binary.Binary $obj | Add-Member -MemberType NoteProperty -Name Hexadecimal -Value $hex.ToUpper() Write-Output $obj } } #endregion #region Exports Export-ModuleMember -Function Convert-DecimalToBinary Export-ModuleMember -Function Convert-BinaryToDecimal Export-ModuleMember -Function Convert-DecimalToHexadecimal Export-ModuleMember -Function Convert-HexadecimalToDecimal Export-ModuleMember -Function Convert-HexadecimalToBinary Export-ModuleMember -Function Convert-BinaryToHexadecimal Export-ModuleMember -Function Convert-Decimal Export-ModuleMember -Function Convert-Binary Export-ModuleMember -Function Convert-Hexadecimal #endregion |