From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:34987) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UIJwW-0007be-Mo for qemu-devel@nongnu.org; Wed, 20 Mar 2013 10:24:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UIJwS-0006H4-W1 for qemu-devel@nongnu.org; Wed, 20 Mar 2013 10:24:40 -0400 Received: from mx1.redhat.com ([209.132.183.28]:12161) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UIJwS-0006Gg-NE for qemu-devel@nongnu.org; Wed, 20 Mar 2013 10:24:36 -0400 Message-ID: <5149C698.9070501@redhat.com> Date: Wed, 20 Mar 2013 08:24:24 -0600 From: Eric Blake MIME-Version: 1.0 References: <1355834518-17989-1-git-send-email-vasilis.liaskovitis@profitbricks.com> <1355834518-17989-8-git-send-email-vasilis.liaskovitis@profitbricks.com> <1363759577.21129.237.camel@liguang.fnst.cn.fujitsu.com> In-Reply-To: <1363759577.21129.237.camel@liguang.fnst.cn.fujitsu.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="----enig2RQLJMQGTFMGHTHJUDRXX" Subject: Re: [Qemu-devel] [RFC PATCH v4 07/30] Add SIZE type to qdev properties List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: li guang Cc: blauwirbel@gmail.com, pingfank@linux.vnet.ibm.com, gleb@redhat.com, stefanha@gmail.com, seabios@seabios.org, qemu-devel@nongnu.org, Vasilis Liaskovitis , kevin@koconnor.net, kraxel@redhat.com, anthony@codemonkey.ws This is an OpenPGP/MIME signed message (RFC 4880 and 3156) ------enig2RQLJMQGTFMGHTHJUDRXX Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 03/20/2013 12:06 AM, li guang wrote: >> + return snprintf(dest, len, "%0.03f%c", (double)*ptr/div, suffixes= [i]); > ^^^^^^ ^^^^^^^^^^^^^^^ =20 >> +} >> + >=20 > IMHO, you may need (double)(*ptr/div), for type cast is right > associated. No, the code as written is correct, and your proposal would be wrong. As written, it is evaluated as: ((double)*ptr) / div which promotes the division to floating point. Your proposal would do the division (*ptr/div) as an integral (truncating) division, and only then cast the result to double. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org ------enig2RQLJMQGTFMGHTHJUDRXX Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.13 (GNU/Linux) Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJRScaYAAoJEKeha0olJ0Nq3DIH/jPh2qZXqtLksIICSik2HU58 gwFOHKRf8ifZFd57tCgJV+yam+PYL9nyXnd4h6FPShQvyRL/d9lD6DjXdx6eCamG LDM8zCu90HClBIrMswS5xb5F7Z/swTPidqRidEN9ChEbF9GYMKD5qeToG+IMZW/w 10nB8tkE1GZfEcnfv6PDxbyxfZABe7MTM0K1tpeaHH6EbmUJHc7v/rfp1wmZVs/Y LA/nDGXOi+92u5lBlxXQnpbM1lpQxmZzAzkxRMkrrKc6+9NcDtwAvOqdmKFohSSF qQ68eQ+WomMAgGRIy0WgOVyo4SejVE/kV8zcoxut4NjRMs+GJlBHbNYIBTkr1tg= =cnbT -----END PGP SIGNATURE----- ------enig2RQLJMQGTFMGHTHJUDRXX--