From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33677) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z9fbF-0001vS-HD for qemu-devel@nongnu.org; Mon, 29 Jun 2015 16:24:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z9fbC-0005wI-1w for qemu-devel@nongnu.org; Mon, 29 Jun 2015 16:24:17 -0400 Received: from hall.aurel32.net ([195.154.112.97]:33247) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z9fbB-0005rp-S5 for qemu-devel@nongnu.org; Mon, 29 Jun 2015 16:24:13 -0400 Date: Mon, 29 Jun 2015 22:24:01 +0200 From: Aurelien Jarno Message-ID: <20150629202401.GN931@aurel32.net> References: <1435259818-6864-1-git-send-email-aurelien@aurel32.net> <55910FCB.30900@twiddle.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <55910FCB.30900@twiddle.net> Subject: Re: [Qemu-devel] [PATCH] target-s390x: fix CONVERT TO BINARY (CVD, CVDY) List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Richard Henderson Cc: qemu-devel@nongnu.org, Alexander Graf 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 aurelien@aurel32.net http://www.aurel32.net