qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: li guang <lig.fnst@cn.fujitsu.com>
Cc: blauwirbel@gmail.com, pingfank@linux.vnet.ibm.com,
	gleb@redhat.com, stefanha@gmail.com, seabios@seabios.org,
	qemu-devel@nongnu.org,
	Vasilis Liaskovitis <vasilis.liaskovitis@profitbricks.com>,
	kevin@koconnor.net, kraxel@redhat.com, anthony@codemonkey.ws
Subject: Re: [Qemu-devel] [RFC PATCH v4 07/30] Add SIZE type to qdev properties
Date: Wed, 20 Mar 2013 08:24:24 -0600	[thread overview]
Message-ID: <5149C698.9070501@redhat.com> (raw)
In-Reply-To: <1363759577.21129.237.camel@liguang.fnst.cn.fujitsu.com>

[-- Attachment #1: Type: text/plain, Size: 708 bytes --]

On 03/20/2013 12:06 AM, li guang wrote:

>> +    return snprintf(dest, len, "%0.03f%c", (double)*ptr/div, suffixes[i]);
>                                     ^^^^^^     ^^^^^^^^^^^^^^^  
>> +}
>> +
> 
> 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.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 621 bytes --]

  reply	other threads:[~2013-03-20 14:24 UTC|newest]

Thread overview: 72+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-18 12:41 [Qemu-devel] [RFC PATCH v4 00/30] ACPI memory hotplug Vasilis Liaskovitis
2012-12-18 12:41 ` [Qemu-devel] [RFC PATCH v4 01/30] [SeaBIOS] Add ACPI_EXTRACT_DEVICE* macros Vasilis Liaskovitis
2013-03-20  3:28   ` li guang
2012-12-18 12:41 ` [Qemu-devel] [RFC PATCH v4 02/30] [SeaBIOS] Add SSDT memory device support Vasilis Liaskovitis
2012-12-18 12:41 ` [Qemu-devel] [RFC PATCH v4 03/30] [SeaBIOS] acpi-dsdt: Implement functions for memory hotplug Vasilis Liaskovitis
2012-12-18 12:41 ` [Qemu-devel] [RFC PATCH v4 04/30] [SeaBIOS] acpi: generate hotplug memory devices Vasilis Liaskovitis
2012-12-18 12:41 ` [Qemu-devel] [RFC PATCH v4 05/30] [SeaBIOS] q35: Add memory hotplug handler Vasilis Liaskovitis
2012-12-18 12:41 ` [Qemu-devel] [RFC PATCH v4 06/30] qapi: make visit_type_size fallback to type_int Vasilis Liaskovitis
2013-01-09  0:18   ` Andreas Färber
2013-01-09 16:00     ` mdroth
2012-12-18 12:41 ` [Qemu-devel] [RFC PATCH v4 07/30] Add SIZE type to qdev properties Vasilis Liaskovitis
2013-03-20  6:06   ` li guang
2013-03-20 14:24     ` Eric Blake [this message]
2013-03-21  0:39       ` li guang
2012-12-18 12:41 ` [Qemu-devel] [RFC PATCH v4 08/30] qemu-option: export parse_option_number Vasilis Liaskovitis
2012-12-18 12:41 ` [Qemu-devel] [RFC PATCH v4 09/30] Implement dimm device abstraction Vasilis Liaskovitis
2013-03-26  3:51   ` li guang
2012-12-18 12:41 ` [Qemu-devel] [RFC PATCH v4 10/30] vl: handle "-device dimm" Vasilis Liaskovitis
2012-12-18 12:41 ` [Qemu-devel] [RFC PATCH v4 11/30] acpi_piix4 : Implement memory device hotplug registers Vasilis Liaskovitis
2012-12-18 12:41 ` [Qemu-devel] [RFC PATCH v4 12/30] acpi_ich9 " Vasilis Liaskovitis
2012-12-18 12:41 ` [Qemu-devel] [RFC PATCH v4 13/30] piix_pci and pc_piix: refactor Vasilis Liaskovitis
2013-01-16  7:20   ` Hu Tao
2013-01-16  9:36     ` Vasilis Liaskovitis
2013-01-16 11:17       ` Andreas Färber
2013-01-16 17:10         ` Vasilis Liaskovitis
2012-12-18 12:41 ` [Qemu-devel] [RFC PATCH v4 14/30] piix_pci: Add i440fx dram controller initialization Vasilis Liaskovitis
2012-12-18 12:41 ` [Qemu-devel] [RFC PATCH v4 15/30] q35: " Vasilis Liaskovitis
2012-12-18 12:41 ` [Qemu-devel] [RFC PATCH v4 16/30] pc: Add dimm paravirt SRAT info Vasilis Liaskovitis
2012-12-18 12:41 ` [Qemu-devel] [RFC PATCH v4 17/30] [SeaBIOS] pci: Use paravirt interface for pcimem_start and pcimem64_start Vasilis Liaskovitis
2012-12-18 12:41 ` [Qemu-devel] [RFC PATCH v4 18/30] Introduce paravirt interface QEMU_CFG_PCI_WINDOW Vasilis Liaskovitis
2012-12-18 12:41 ` [Qemu-devel] [RFC PATCH v4 19/30] Implement "info memory-total" and "query-memory-total" Vasilis Liaskovitis
2012-12-19 19:47   ` Blue Swirl
2013-01-04 16:21   ` Eric Blake
2013-01-10 17:42     ` Vasilis Liaskovitis
2012-12-18 12:41 ` [Qemu-devel] [RFC PATCH v4 20/30] balloon: update with hotplugged memory Vasilis Liaskovitis
2012-12-18 12:41 ` [Qemu-devel] [RFC PATCH v4 21/30] Implement dimm-info Vasilis Liaskovitis
2013-01-08 23:20   ` Eric Blake
2013-01-10 17:45     ` Vasilis Liaskovitis
2012-12-18 12:41 ` [Qemu-devel] [RFC PATCH v4 22/30] [SeaBIOS] acpi: add _EJ0 operation and eject port for memory devices Vasilis Liaskovitis
2012-12-18 12:41 ` [Qemu-devel] [RFC PATCH v4 23/30] dimm: add hot-remove capability Vasilis Liaskovitis
2012-12-18 12:41 ` [Qemu-devel] [RFC PATCH v4 24/30] acpi_piix4: " Vasilis Liaskovitis
2012-12-18 12:41 ` [Qemu-devel] [RFC PATCH v4 25/30] acpi_ich9: " Vasilis Liaskovitis
2012-12-19 19:48   ` Blue Swirl
2012-12-18 12:41 ` [Qemu-devel] [RFC PATCH v4 26/30] Implement qmp and hmp commands for notification lists Vasilis Liaskovitis
2013-01-09  0:23   ` Eric Blake
2012-12-18 12:41 ` [Qemu-devel] [RFC PATCH v4 27/30] [SeaBIOS] Add _OST dimm method Vasilis Liaskovitis
2012-12-18 12:41 ` [Qemu-devel] [RFC PATCH v4 28/30] Add _OST dimm support Vasilis Liaskovitis
2012-12-18 12:41 ` [Qemu-devel] [RFC PATCH v4 29/30] [SeaBIOS] Implement _PS3 method for memory device Vasilis Liaskovitis
2012-12-18 12:41 ` [Qemu-devel] [RFC PATCH v4 30/30] Implement _PS3 for dimm Vasilis Liaskovitis
2012-12-18 16:45 ` [Qemu-devel] [RFC PATCH v4 00/30] ACPI memory hotplug Zhi Yong Wu
2012-12-19 11:40   ` Vasilis Liaskovitis
2012-12-19  7:27 ` Gerd Hoffmann
2012-12-19 11:35   ` Vasilis Liaskovitis
2012-12-19 13:56     ` Gerd Hoffmann
2013-01-10 18:57     ` Vasilis Liaskovitis
2013-03-19  6:30       ` li guang
2013-03-26 16:58         ` Vasilis Liaskovitis
2013-03-27  2:42           ` li guang
2013-04-02  9:15       ` liu ping fan
2013-01-09  0:08 ` Andreas Färber
2013-01-10 17:36   ` Vasilis Liaskovitis
2013-01-10 17:55     ` Andreas Färber
2013-03-20  6:18   ` li guang
2013-03-26 14:20     ` Eduardo Habkost
2013-03-27  7:39       ` li guang
     [not found] ` <CAF+CadtnTcOnUt7jp1bARJgioxR5KzLG0QSQuDbiqhiKxiCqFA@mail.gmail.com>
     [not found]   ` <20130228101819.GA4370@dhcp-192-168-178-175.profitbricks.localdomain>
2013-03-19  7:28     ` li guang
2013-03-26 16:43       ` Vasilis Liaskovitis
2013-03-27  2:54         ` li guang
2013-03-28  9:29           ` Vasilis Liaskovitis
2013-03-28  9:49             ` liu ping fan
2013-03-26 14:47 ` Luiz Capitulino
2013-03-26 16:59   ` Vasilis Liaskovitis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5149C698.9070501@redhat.com \
    --to=eblake@redhat.com \
    --cc=anthony@codemonkey.ws \
    --cc=blauwirbel@gmail.com \
    --cc=gleb@redhat.com \
    --cc=kevin@koconnor.net \
    --cc=kraxel@redhat.com \
    --cc=lig.fnst@cn.fujitsu.com \
    --cc=pingfank@linux.vnet.ibm.com \
    --cc=qemu-devel@nongnu.org \
    --cc=seabios@seabios.org \
    --cc=stefanha@gmail.com \
    --cc=vasilis.liaskovitis@profitbricks.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).