Debian Codegraph @

gcc/testsuite/c-c++-common/dfp/compare-eq-const.c

raw
1 /* C99 6.5.9 Equality operators.
2 Compare decimal float constants against each other. */
3 /* { dg-additional-options "-fexcess-precision=fast" } */
4
5 #include "dfp-dbg.h"
6
7 extern void link_error (void);
8
9 int
10 main ()
11 {
12 /* Compare like-typed positive constants. */
13 if (2.0df != 2.0df)
14 link_error ();
15
16 /* Compare decimal float constants of different types. */
17 if (500e-2dl != 0.05e2df)
18 link_error ();
19
20 /* Binary floating point introduces errors to decimal values. */
21 if (1.4 + 1.4 + 1.4 == 4.2)
22 link_error ();
23
24 /* But, this looks more like what one would expect. */
25 if (1.4dd + 1.4dd + 1.4dd != 4.2dd)
26 link_error ();
27
28 FINISH
29 }