Edited toBitArray method to include negative numbers conversion