delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2010/06/12/09:51:51

X-Recipient: archive-cygwin AT delorie DOT com
X-SWARE-Spam-Status: No, hits=-0.5 required=5.0 tests=AWL,BAYES_50,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,T_RP_MATCHES_RCVD,T_TO_NO_BRKTS_FREEMAIL
X-Spam-Check-By: sourceware.org
Message-ID: <4C1390E8.4020002@aol.com>
Date: Sat, 12 Jun 2010 06:51:36 -0700
From: Tim Prince <n8tm AT aol DOT com>
Reply-To: tprince AT computer DOT org
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.9) Gecko/20100317 Thunderbird/3.0.4
MIME-Version: 1.0
To: cygwin AT cygwin DOT com
Subject: Re: bug in NINT() in gfortran
References: <7E93C5822639AC4B917B413898A805AA7769505D37 AT ADM-EXMBX0CD DOT adm DOT c DOT sdu DOT dk>
In-Reply-To: <7E93C5822639AC4B917B413898A805AA7769505D37@ADM-EXMBX0CD.adm.c.sdu.dk>
x-aol-global-disposition: G
X-AOL-SCOLL-SCORE: 0:2:355761312:93952408
X-AOL-SCOLL-URL_COUNT: 0
x-aol-sid: 3039ac1d33864c1390e92653
X-AOL-IP: 99.13.231.72
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

On 6/12/2010 12:07 AM, Hans Jørgen Aagaard Jensen wrote:
> The NINT() intrinsic in current gfortran under cygwin has a bug. Below follows:
> 1) small test program
> 2) output from this program
> 3) output from "gfortran -v"
>
> (I am not submitting this to the gcc bugzilla, because the test worked OK on all the linux systems I tested.)
> (I found the error becaus our quantum chemistry softward dirac (http://dirac.chem.sdu.dk) failed a few of the internal tests.)
>
>    -- Hans Jørgen Aa. Jensen
>
> ======= 1) small test program ============
>        program test
>        double precision xval
>        xval = 132843.61283756854D0
>        do i = 1,7
>           ipoint = nint(xval)
>           write (6,*), xval, ipoint
>           xval = 10.0d0*xval
>        end do
>        return
>        end
> ======= 1) output =============
>     132843.61283756854           132844
>     1328436.1283756853      -1596096578
>
>    

Try the following replacement for nint():
     ipoint = xval+.5
which leads me to believe the lround function from newlib is buggy.
If you wished to handle negative as well as positive, the work-around
         ipoint = xval+sign(.5,xval)
would take it a little further.  This short-cuts the distinction between 
ieee_nearest and legacy Fortran rounding style, but I don't see that 
gfortran was making the distinction.

-- 
Tim Prince


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019