Updated to work with negative integers and to throw errors and warnings where appropriate for out of range warnings.