shift left/right: Shifting means exactly that, shift all the bits in the first operand either left or right the number of time indicated in the second. The second operand should be an integer value. If it is not, then truncate it (pretend the fractional part does not exist). If a shift left would push a bit off of the 'front', it is lost and causes an overflow. Report the overflow and print the bits left over after the shift. If a shift right would push a bit off of the 'back', it is lost and causes an underflow. Report the underflow and print the bits left over after the shift. e.g. (shift 2 to the left 1 time .. in essence multiply by 2) $ ./compu "000101000010" $ OKAY 1000
(shift 2 to the left 1.5 times .. not an int) $ ./compu "000101000011" $ NINT 1000
(shift 2 to the left 2 times .. in essence multiply by 4, but we can't represent 8) $ ./compu "000101000100" $ AOVR 0000
(shift 1.0 to the left 1 time .. in essence divide by 2) $ ./compu "001000100010" $ OKAY 0001 (shift 1.0 to the left 2 times.. in essence divide by 4, but we can't represent 1/4) $ ./compu "001000100100" $ AUDR 0000 Note! If you have more than one flag on an operation, output all that apply in the order they are listed above. Only if there are no errors and no other flags should you print "OKAY". Shift is the only operation that may result in a "NINT" flag and a "AOVR" or "AUDR" flag.
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here