From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34785) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z9oUj-0007UG-5l for qemu-devel@nongnu.org; Tue, 30 Jun 2015 01:54:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z9oUd-0004e2-HU for qemu-devel@nongnu.org; Tue, 30 Jun 2015 01:54:09 -0400 Received: from mail-qg0-x233.google.com ([2607:f8b0:400d:c04::233]:33630) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z9oUd-0004dw-Ci for qemu-devel@nongnu.org; Tue, 30 Jun 2015 01:54:03 -0400 Received: by qgem68 with SMTP id m68so24355446qge.0 for ; Mon, 29 Jun 2015 22:54:02 -0700 (PDT) Sender: Richard Henderson References: <1435259818-6864-1-git-send-email-aurelien@aurel32.net> <55910FCB.30900@twiddle.net> <20150629202401.GN931@aurel32.net> From: Richard Henderson Message-ID: <55922EF6.4050605@twiddle.net> Date: Tue, 30 Jun 2015 06:53:58 +0100 MIME-Version: 1.0 In-Reply-To: <20150629202401.GN931@aurel32.net> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit 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: Aurelien Jarno Cc: qemu-devel@nongnu.org, Alexander Graf On 06/29/2015 09:24 PM, Aurelien Jarno wrote: > 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. > Ah, true enough. I suppose adding a 32-bit unsigned variable with which to do the division is more trouble than it's worth. Reviewed-by: Richard Henderson r~