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] |

*From*: Brooks Moses <bmoses at stanford dot edu>*To*: fortran at gcc dot gnu dot org*Cc*: gcc-patches at gcc dot gnu dot org*Date*: Thu, 19 Oct 2006 14:39:29 -0700*Subject*: Re: [PATCH][4.3] Expand lround inline for x86_64/i?86 SSE math*Organization*: Stanford University*References*: <Pine.LNX.4.64.0610181606580.8942@zhemvz.fhfr.qr> <EEA92755-FDBD-4FF8-AAAB-ACBB9461A6F7@adacore.com> <9645931.1161211060458.JavaMail.root@dtm1eusosrv72.dtm.ops.eu.uu.net> <4537C969.5080509@moene.indiv.nluug.nl> <4537DC19.5000301@stanford.edu> <84fc9c000610191336m4462380x2394ae0232605628@mail.gmail.com>

On 10/19/06, Brooks Moses <bmoses@stanford.edu> wrote:Toon Moene wrote:Richard Guenther wrote:I wonder if fortran specifies round differently, as the frontend explicitly converts NINT(x) = INT(x + ((x > 0) ? 0.5 : -0.5)).

Yep - sorry, don't have the reference handy.

For what it's worth, since I do have the reference handy, that's essentially a direct translation of how the Fortran 95 standard defines the NINT intrinsic.

So, does it define how the x + 0.5 is carried out with respect to intermediate rounding before converting to INT? Literaly writing the above yields 1.0 for NINT ( 0.5 - epsilon ) assuming the hardware rounds to nearest even for the addition.

It doesn't define this, so far as I am aware -- and, really, I'm not at all sure whether the standard authors intended the description to be interpreted as exact math, or as numerically-approximate math.

program nint_bug real :: x x = 0.5 - epsilon(x)/4.0 write(*,*) x - 0.5, nint(x) if (nint(x) /= 0) call abort end program

**Follow-Ups**:**Re: [PATCH][4.3] Expand lround inline for x86_64/i?86 SSE math***From:*Steve Kargl

Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|

Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |