d0676d5dfa7eb0bde37309de2c721cc9df32e9b0
[alexxy/gromacs.git] / cmake / TestFloatFormat.c
1 int
2 main()
3 {
4   /* Check that a double is 8 bytes - compilation dies if it isnt */
5   extern char xyz [sizeof(double) == 8 ? 1 : -1];
6   int i;
7   double d;
8
9   double abc [10] = {
10     /* Zero-terminated strings encoded as floating-point numbers */
11     /* "GROMACSX" in ascii    */
12     (double)  3.80279098314984902657e+35 , (double) 0.0,
13     /* "GROMACSX" in ebcdic   */
14     (double) -1.37384666579378297437e+38 , (double) 0.0,
15     /* "D__float" (vax)       */
16     (double)  3.53802595280598432000e+18 , (double) 0.0,
17     /* "IBMHEXFP" s390/ascii  */
18     (double)  1.77977764695171661377e+10 , (double) 0.0,
19     /* "IBMHEXFP" s390/ebcdic */
20     (double) -5.22995989424860458374e+10 , (double) 0.0,
21   };
22
23   /* Make sure some compilers do not optimize away the entire structure
24    * with floating-point data by using it to produce a return value.
25    */
26   for(i=0,d=0;i<10;i++)
27   {
28     d+=abc[i];
29   }
30
31   return (d==12345.0);
32 }