[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] softfloat missing functions

From: Julian Seward
Subject: Re: [Qemu-devel] [PATCH] softfloat missing functions
Date: Mon, 19 Mar 2007 22:53:40 +0000
User-agent: KMail/1.9.5

Thinking about this more, you ask "is this correct", but that
is only meaningful if you say what the specification is.  
Correct relative to what?

> 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;
> }

If a is NaN then so is the argument to llrint.  'man llrint' says:

  If x is infinite or NaN, or if the rounded value is
  outside  the  range  of  the  return type, the numeric result
  is unspecified. 

So then float64_to_uint64 produces an unspecified result.

It seems to me much safer to test and handle NaN, Inf and
out-of-range values specially.  However, even that does not help
unless you say what the specification is.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]