fesetround problem

Corinna Vinschen corinna-cygwin@cygwin.com
Wed May 2 07:45:00 GMT 2012


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



More information about the Cygwin mailing list