qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH 07/12] ARM: Return correct result for float-to-i


From: Nathan Froyd
Subject: Re: [Qemu-devel] [PATCH 07/12] ARM: Return correct result for float-to-integer conversion of NaN
Date: Mon, 29 Nov 2010 08:38:42 -0800
User-agent: Mutt/1.5.17+20080114 (2008-01-14)

On Tue, Nov 23, 2010 at 06:53:46PM +0000, Peter Maydell wrote:
> The ARM architecture mandates that converting a NaN value to
> integer gives zero (if Invalid Operation FP exceptions are
> not being trapped). This isn't the behaviour of the SoftFloat
> library, so NaNs must be special-cased.
> 
> +/* Helper routines to identify NaNs. Note that softfloat's
> + * floatxx_is_nan() actually only returns true for quiet NaNs.
> + * A NaN has an exponent field all 1s and a fraction field
> + * anything except all zeros. Conveniently we can detect this
> + * by masking out the sign bit and doing an unsigned comparison.
> + */
> +static int float32_is_any_nan(float32 x)
> +{
> +    return ((float32_val(x) & ~(1 << 31)) > 0x7f800000UL);
> +}
> +
> +static int float64_is_any_nan(float64 x)
> +{
> +    return ((float64_val(x) & ~(1ULL << 63)) > 0x7ff0000000000000ULL);
> +}

Why not just use:

static int float32_is_any_nan(float32 x)
{
  return float32_is_nan(x) || float32_is_signaling_nan(x);
}

and likewise for the 64-bit case?

-Nathan



reply via email to

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