We’ve looked at the binary functions – now its time to look at the hex functions starting with addition.

001
002 003 004 005 006 007 008 009 010 011 012 013 014 |
function Get-HexSum {
param( [string]$inputvalue1, [string]$inputvalue2 ) ## check valid hex numbers Test-Hex $inputvalue1 Test-Hex $inputvalue2 $sum = (ConvertTo-Decimal -inputvalue $inputvalue1 -hex) ` ConvertTo-Hex -inputvalue $sum |

This is a direct copy of the binary addition function – just changed to accept hex input instead.

Again we test the hex number is actually hex – convert to decimal, add, and convert back to hex

Establishing a pattern helps make things easier for producing related functions.