qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Peter Maydell <peter.maydell@linaro.org>
To: Eric Blake <eblake@redhat.com>
Cc: Bharata B Rao <bharata@linux.vnet.ibm.com>,
	QEMU Developers <qemu-devel@nongnu.org>,
	David Gibson <david@gibson.dropbear.id.au>,
	"qemu-ppc@nongnu.org" <qemu-ppc@nongnu.org>,
	Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>,
	Richard Henderson <rth@twiddle.net>
Subject: Re: [Qemu-devel] [RFC PATCH v0] softfloat: Add round-to-odd rounding mode
Date: Thu, 19 Jan 2017 15:20:34 +0000	[thread overview]
Message-ID: <CAFEAcA8581hwSXXUSqLgFiJaFrfTTsnFJ0hwjD5neR_MJ5AtmA@mail.gmail.com> (raw)
In-Reply-To: <8b867af9-a039-f0de-9072-77c2a260ec23@redhat.com>

On 19 January 2017 at 14:47, Eric Blake <eblake@redhat.com> wrote:
> On 01/18/2017 11:14 PM, Bharata B Rao wrote:
>> round-to-odd mode is explained as under:
>>
>> Let Z be the intermediate arithmetic result or the operand of a convert
>> operation. If Z can be represented exactly in the target format, the
>> result is Z. Otherwise the result is either Z1 or Z2 whichever is odd.
>> Here Z1 and Z2 are the next larger and smaller numbers representable
>> in the target format respectively.
>
> IEEE 854 and thus POSIX <float.h> specifies round-to-zero,
> round-to-pos-inf, round-to-neg-inf, and round-to-even. It sounds like
> round-to-odd is similar to round-to-even, only that the ties are broken
> in the opposite direction.

No, round-to-even does "round ties to even" -- the rounding is
to the closest representable number, and only if the two
surrounding numbers are both equally near do we pick the even
one. round-to-odd is "always round to the odd number, even
if that's much further from the infinitely-precise result
than the even number is". (This is also sometimes called
von Neumann rounding or sticky rounding -- the motivation is
that you can for instance do 64bit -> 32bit -> 16bit
conversions in two steps without double rounding errors if
you do the first conversion with round-to-odd.)

thanks
-- PMM

  reply	other threads:[~2017-01-19 15:20 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-19  5:14 [Qemu-devel] [RFC PATCH v0] softfloat: Add round-to-odd rounding mode Bharata B Rao
2017-01-19 12:11 ` Peter Maydell
2017-01-19 14:47 ` Eric Blake
2017-01-19 15:20   ` Peter Maydell [this message]
2017-01-19 15:29 ` Richard Henderson
2017-01-19 15:44   ` Peter Maydell
2017-01-20  9:20   ` Bharata B Rao

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=CAFEAcA8581hwSXXUSqLgFiJaFrfTTsnFJ0hwjD5neR_MJ5AtmA@mail.gmail.com \
    --to=peter.maydell@linaro.org \
    --cc=bharata@linux.vnet.ibm.com \
    --cc=david@gibson.dropbear.id.au \
    --cc=eblake@redhat.com \
    --cc=nikunj@linux.vnet.ibm.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    --cc=rth@twiddle.net \
    /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).