Changed bit-based implementation to decimal-based implementation.