Forum Discussion
Altera_Forum
Honored Contributor
16 years ago --- Quote Start --- I think I might know what's going on here. The double precision constants are being treated as single precision constants. ... --- Quote End --- Yes - this is the reason. Thanks a lot for that! I found one more workaround with constants - they must be marked with 'L' - suffix as long double. Long double constant will be converted properly into double. I wrote one more simple program, #include <stdio.h> /* #pragma no_custom_fadds #pragma no_custom_fsubs #pragma no_custom_fmuls #pragma no_custom_fdivs */ double a, b, c; int main( void ) { // Long double constant will be converted properly into double a = 1.000000000000011L; b = 1.000000000000004L; c = 1e-7L; printf ("a = %.15f\n", a); printf ("b = %.15f\n", b); printf ("c = %.15f\n", c); printf ("a+b+c*c = %.15f\n", a+b+c*c); // prints correct double precision result while (1); return 0; } result: a = 1.000000000000011 b = 1.000000000000004 c = 0.000000100000000 a+b+c*c = 2.000000000000025