[Top][All Lists]

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

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

From: J. Mayer
Subject: Re: [Qemu-devel] [PATCH] softfloat missing functions
Date: Tue, 20 Mar 2007 00:13:29 +0100

On Mon, 2007-03-19 at 22:53 +0000, Julian Seward wrote:
> 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.

Well, you are right, but the function float64_to_int64 acts the same way
in that code.
If we want to follow IEEE compliance, we have to use the softfloat
functions instead, not the softfloat-native ones. Or we should sanitize
the whole softfloat.c code, to be consistent, it seems.

Here's an updated patch, with two more functions. The added functions
float32 uint32_to_float32(unsigned int v STATUS_PARAM)
float64 uint32_to_float64(unsigned int v STATUS_PARAM)
float32 uint64_to_float32( uint64_t v STATUS_PARAM)
float64 uint64_to_float64( uint64_t v STATUS_PARAM)
unsigned int float32_to_uint32( float32 a STATUS_PARAM)
unsigned int float32_to_uint32_round_to_zero( float32 a STATUS_PARAM)
unsigned int float64_to_uint32( float64 a STATUS_PARAM)
unsigned int float64_to_uint32_round_to_zero( float64 a STATUS_PARAM)
uint64_t float64_to_uint64 (float64 a STATUS_PARAM)
uint64_t float64_to_uint64_round_to_zero (float64 a STATUS_PARAM)

Note that some of those functions already exist in softfloat.c but not
in softfloat-native.c.

J. Mayer <address@hidden>
Never organized

Attachment: qemu_softfloat.diff
Description: Text Data

reply via email to

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