qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "J. Mayer" <l_indien@magic.fr>
To: qemu-devel@nongnu.org
Subject: [Fwd: Re: [Qemu-devel] [PATCH] softfloat missing functions]
Date: Mon, 19 Mar 2007 23:38:36 +0100	[thread overview]
Message-ID: <1174343916.24702.26.camel@rapid> (raw)

Repost: looks like this message never reached the list....

-------- Forwarded Message --------
> From: J. Mayer <l_indien@magic.fr>
> To: Julian Seward <jseward@acm.org>
> Cc: qemu-devel@nongnu.org
> Subject: Re: [Qemu-devel] [PATCH] softfloat missing functions
> Date: Mon, 19 Mar 2007 22:10:14 +0100
> 
> On Mon, 2007-03-19 at 20:37 +0000, Julian Seward wrote:
> > > Note that float64_to_uint64 functions are not correct, as they won't
> > > return results between INT64_MAX and UINT64_MAX. Hope someone may know
> > > the proper solution for this.
> > 
> > How about this?
> 
> Yes, it seems to be the correct way, but thinking more about the
> problem, it appeared to me that the implementation could be even easier
> than yours. It seems to me that this may be sufficient:
> uint64_t float64_to_uint64 (float64 a STATUS_PARAM)
> {
>     int64_t v;
> 
>     v = llrint(a + (float64)INT64_MIN);
> 
>     return v - INT64_MIN;
> }
> uint64_t float64_to_uint64_round_to_zero (float64 a STATUS_PARAM)
> {
>     int64_t v;
> 
>     v = (int64_t)(a + (float64)INT64_MIN);
> 
>     return v - INT64_MIN;
> }
> 
> For "not-native" softfloat, this gives:
> uint64_t float64_to_uint64 (float64 a STATUS_PARAM)
> {
>     int64_t v;
> 
>     v = int64_to_float64(INT64_MIN STATUS_VAR);
>     v = float64_to_int64((a + v) STATUS_VAR);
> 
>     return v - INT64_MIN;
> }
> 
> uint64_t float64_to_uint64_round_to_zero (float64 a STATUS_PARAM)
> {
>     int64_t v;
> 
>     v = int64_to_float64(INT64_MIN STATUS_VAR);
>     v = float64_to_int64_round_to_zero((a + v) STATUS_VAR);
> 
>     return v - INT64_MIN;
> }
> 
> This should also give the correct result for NaN and overflows, if we
> rely to the fact float64_to_int64 is correct. Please tell me if I'm
> wrong !
> 
-- 
J. Mayer <l_indien@magic.fr>
Never organized

                 reply	other threads:[~2007-03-19 22:40 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=1174343916.24702.26.camel@rapid \
    --to=l_indien@magic.fr \
    --cc=qemu-devel@nongnu.org \
    /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).