Bytes
Write a function called IsValidByte which takes a string as its argument and returns TRUE if the string has exactly 8 characters which are all “0” or “1”. For example:
- IsValidByte(“01101010”) should return TRUE
- IsValidByte(“1101010”) and IsValidByte(“01201101”) should both return FALSE.
Extension
Write a function called AddBytes which takes two valid strings representing bytes as its arguments and returns a string which represents the sum of the two bytes using Binary arithmetic. For example:
- AddBytes(“10010100”, “01001101”) should return “11100001”
- Note that you are NOT ALLOWED to convert these strings to their equivalent integers!
Extension: How does your function cope with overflow?).