This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH][4.3] Expand lround inline for x86_64/i?86 SSE math


Steve Kargl wrote:
On Thu, Oct 19, 2006 at 03:34:23PM -0700, Steve Kargl wrote:
It states that NINT(X) = INT(X+0.5) for X > 0. You then
find INT(A) = 0 for |A| < 1. A quick scan over the section
on numeric binary operators did not reveal the normal weasel words, but I suspect that the result of X+0.5 is a
processor-dependent approximation and round-to-nearest
meets that criterium.


OTOH, I think it is a bug because we can choose a better
algorithm to determine if x+0.5 is truly less than 1.
See for example round[f] in intrinsics/c99_functions.c

Upon further review, the standard says NINT(X) = INT(X+0.5)
for X > 0. So, if and when someone makes a change to the
inlining of NINT(X), its result needs to agree with
INT(X+0.5).

Note, though, the complete change of language in the definition of NINT in the Fortran 2003 standard. In the pathological cases where they might arguably be held to require different things, I think we should be following the later language.


Beyond that, I am also somewhat dubious about the idea that the language you cite was really meant to mean that NINT(X) must be subject to exactly the same rounding errors as INT(X+0.5). I think that's the same sort of splitting too fine a hair that Richard Maine told me I was doing when I claimed a few months ago that DATA I/.../ and I=... were required to treat the largest negative integer differently. :)

- Brooks


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]