On 2015-06-29 10:28, Richard Henderson wrote: > On 06/25/2015 08:16 PM, Aurelien Jarno wrote: > > for (shift = 4; (shift < 64) && bin; shift += 4) { > >- int current_number = bin % 10; > >- > >- dec |= (current_number) << shift; > >+ dec |= (bin % 10) << shift; > > bin /= 10; > > } > > You've changed from 32-bit division to 64-bit division just to solve a > problem with the shift. Better to just change the type of current_number > there.
Changing the type of current_number instead of bin would indeed solve the shift issue, but not the -2^31 case. As we take the absolute value, we need a 64-bit variable to hold the corresponding 2^31 value. -- Aurelien Jarno GPG: 4096R/1DDD8C9B aurel...@aurel32.net http://www.aurel32.net