https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113455

--- Comment #5 from newbie-02 <newbie-02 at gmx dot de> ---
> If you're doing arithmetic with constant operands, it might be folded at 
> compile time; make sure you're using -frounding-math to avoid that.  

hmmmmm... that issue is left. From your comment I was in hope the following
program would work:  
````  
// compile with 'gcc -std=gnu99 -I/usr/local/include/dfp -frounding-math -o
round_constants_ties_away round_constants_ties_away.c -ldfp', 

#define __STDC_WANT_DEC_FP__                                                   
        // req. for decimal rounding mode, 
#include <fenv.h>                                                              
        // req. for decimal rounding mode, 
#include <stdio.h>                                                             
        // reg. e.g. printf and perror, 

int main( int argc, char *argv[ ] ) { 
        fe_dec_setround( 4 ); 
        printf( "fe_dec_rounding_mode : %d \n", fe_dec_getround() ); 
        volatile _Decimal64 x1DD = 8.0000000000000015DD; 
        volatile _Decimal64 x2DD = 8.0000000000000025DD; 

        printf( "Read in of 8.0000000000000015 produced : %.17DE \n", x1DD ); 
        printf( "Read in of 8.0000000000000025 produced : %.17DE \n", x2DD ); 
        printf( "In operation it works                  : %.17DE \n", x2DD +
5E-16DD ); 

        return( 0 ); 
} 
````  

It works, but doesn't round the constants as wanted:  

````  
└─$ ./round_constants_ties_away                                                 
fe_dec_rounding_mode : 4 
Read in of 8.0000000000000015 produced : 8.00000000000000200E+00 
Read in of 8.0000000000000025 produced : 8.00000000000000200E+00 
In operation it works                  : 8.00000000000000300E+00 
````

Reply via email to