Thread Links Date Links
Thread Prev Thread Next Thread Index Date Prev Date Next Date Index

Re: roundTiesToEven in precision 1



To: Vincent Lefevre <vincent@xxxxxxxxxx>
Cc: stds-754@xxxxxxxxxxxxxxxxx,
        Dan Zuras Intervals <intervals08@xxxxxxxxxxxxxx>
From: Dan Zuras Intervals <intervals08@xxxxxxxxxxxxxx>
Subject: Re: roundTiesToEven in precision 1 Date: Tue, 24 Mar 2009 21:28:59 -0700


	Vincent,

	I'm not quite sure what you mean by precision 1 but the
	context of your question suggests that 754 breaks down
	when p = 1.

	So, if you are suggesting that things break down when
	one goes to so small a precision, I think this is likely.

	We debated making some statement about this in the text
	of the standard but as the whole purpose of extended &
	extendable precisions was to go beyond the other precisions
	available, we thought it an unnecessary thing to point out.

	Still, I believe you are correct.

	Yours,

				Dan


Date: Wed, 25 Mar 2009 01:56:08 +0100
From: Vincent Lefevre <vincent@xxxxxxxxxx>
To: stds-754@xxxxxxxxxxxxxxxxx
Subject: roundTiesToEven in precision 1

The IEEE 754-2008 standard says:

  4.3.1 Rounding-direction attributes to nearest
  [...]
  --- roundTiesToEven, the floating-point number nearest to the
      infinitely precise result shall be delivered; if the two
      nearest floating-point numbers bracketing an unrepresentable
      infinitely precise result are equally near, the one with an
      even least significant digit shall be delivered

However this rule cannot appply in precision 1 for the numbers with
the infinitely precise significand b - 1/2 (b being even). Indeed
the two nearest floating-point numbers bracketing this value are b-1
(whose precision-1 significand is b-1, an odd number) and b (whose
precision-1 significand is 1, also an odd number).

The standard should have specified this particular case. For the next
revision, I suggest that one should consider the exponent of the value
that is closer to 0, then consider the significands of both bracketing
values, and choose the even one. With the above example, the exponent
of b-1 would be chosen, i.e. 0; then the significands are respectively
b-1 and b, and the result b should be returned since b is even.

This choice matches the existing practice at least under Linux and
Mac OS X. For instance, the following program

#include <stdio.h>

int main (void)
{
  double x;

  for (x = 1.5; x <= 9.5; x += 1.0)
    printf ("x = %g -> %.1g\n", x, x);

  return 0;
}

outputs:

x = 1.5 -> 2
x = 2.5 -> 2
x = 3.5 -> 4
x = 4.5 -> 4
x = 5.5 -> 6
x = 6.5 -> 6
x = 7.5 -> 8
x = 8.5 -> 8
x = 9.5 -> 1e+01

--
Vincent Lefèvre <vincent@xxxxxxxxxx> - Web: <http://www.vinc17.org/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.org/blog/>
Work: CR INRIA - computer arithmetic / Arenaire project (LIP, ENS-Lyon)

--IYDRadKeTKEZZUQcFXGBNZXFKELbQS--