test for is.logical in function negate.
test for size > 0 instead of size != 0 in function shiftLeft and shiftRight.