[Top][All Lists]

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

Re: [Qemu-ppc] [RFC PATCH v1] softfloat: Add round-to-odd rounding mode

From: Peter Maydell
Subject: Re: [Qemu-ppc] [RFC PATCH v1] softfloat: Add round-to-odd rounding mode
Date: Fri, 20 Jan 2017 11:46:56 +0000

On 20 January 2017 at 11:36, Bharata B Rao <address@hidden> wrote:
> On Fri, Jan 20, 2017 at 10:28:22AM +0000, Peter Maydell wrote:
>> This isn't sufficient, because it won't do the right thing
>> in the code which is picking between "round to infinity" and
>> "round to largest/smallest representable number". That's
>> phrased differently from the Float128 code but it's still
>> there:
>>             return packFloat64( zSign, 0x7FF, - ( roundIncrement == 0 ));
>> will generate a result with an all-zeros mantissa for
>> roundIncrement == 0 (ie go to infinity) and an all-ones
>> mantissa otherwise (ie go to largest-representable).
>> That works for the existing cases but it doesn't work
>> for round_to_odd.
> Based on my understanding of your and Richard's clarification, we
> shouldn't overflow to infinity in round-to-odd mode. Like I did for 128 bit
> case where we return the max possible value in the similar situation, I
> suppose we should explicitly take care of returning max 64bit value here
> for round-to-odd case ?

I would suggest something like
  bool overflow_to_inf = roundingMode != float_round_to_odd &&
      roundIncrement != 0;

  float_raise(float_flag_overflow | float_flag_inexact, status);
  return packFloat64(zSign, 0x7FF, -(!overflow_to_inf));

as the contents of the if() {} body for overflow detected.

-- PMM

reply via email to

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