delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2012/05/02/03:46:00

X-Recipient: archive-cygwin AT delorie DOT com
X-Spam-Check-By: sourceware.org
Date: Wed, 2 May 2012 09:45:02 +0200
From: Corinna Vinschen <corinna-cygwin AT cygwin DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: fesetround problem
Message-ID: <20120502074502.GB2972@calimero.vinschen.de>
Reply-To: cygwin AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
References: <4FA0291E DOT 8040806 AT prolingua DOT co DOT uk>
MIME-Version: 1.0
In-Reply-To: <4FA0291E.8040806@prolingua.co.uk>
User-Agent: Mutt/1.5.21 (2010-09-15)
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT 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 May  1 19:19, David Matthews wrote:
> fesetround seems to be broken in the current version of Cygwin.  It
> returns EINVAL for any argument other than FE_TONEAREST.  The
> following snippet works fine on Debian wheezy but shows a non-zero
> return in Cygwin.
> 
> #include <fenv.h>
> #include <stdio.h>
> 
> int main()
> {
>     int r = fesetround(FE_TOWARDZERO);
>     printf("fesetround returned %d.  Current rounding is %d\n",
>            r, fegetround());
>     return 0;
> }
> 
> Browsing the CVS source it looks as though the problem is the line
> in fesetround in fenv.c that says:
> 
>   if (round & ~(FE_CW_ROUND_MASK >> FE_CW_PREC_SHIFT))
> 
> I think FE_CW_PREC_SHIFT should be FE_CW_ROUND_SHIFT to match
> fegetround above.

Thanks for the report and the testcase.

Actually, the test for the input parameter should not shift it at all,
otherwise invalid input, for instance, 0xf0000000, would be treated as a
valid input of 0.  The fesetprec function had the same problem.  I fixed
that by explicitely only allowing the valid input range.


Thanks again,
Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat

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