aboutsummaryrefslogtreecommitdiffstats
path: root/trio/compare.c
blob: 3823aa2de32005e4d2482a456e5e899d2251abbe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include "trio.h"

#define compare(format, value) printf("FORMAT: %s\n", format); printf("TRIO: "); trio_printf(format,value); printf("\nLIBC: "); \
printf(format,value); printf("\n\n"); 

int main()
{
   compare("\"%e\"",2.342E+02);
   compare("\"%10.4e\"",-2.342E-02);
   compare("\"%11.4e\"",-2.342E-02);
   compare("\"%12.4e\"",-2.342E-02);
   compare("\"%13.4e\"",-2.342E-02);
   compare("\"%14.4e\"",-2.342E-02);
   compare("\"%15.4e\"",-2.342E-02);
   compare("\"%16.4e\"",-2.342E-02);
   compare("\"%16.4e\"",-2.342E-22);
   compare("\"%G\"",-2.342E-02);
   compare("\"%G\"",3.1415e-6);
   compare("%016e", 3141.5);
   compare("%16e", 3141.5);
   compare("%-16e", 3141.5);
   compare("%010.3e", 3141.5);

   compare("*%5f*", 3.3);
   compare("*%5f*", 3.0);
   compare("*%5f*", .999999E-4);
   compare("*%5f*", .99E-3);
   compare("*%5f*", 3333.0);

   compare("*%5g*", 3.3);
   compare("*%5g*", 3.0);
   compare("*%5g*", .999999E-4);
   compare("*%5g*", .99E-3);
   compare("*%5g*", 3333.0);
   compare("*%5g*", 0.01);

   compare("*%5.g*", 3.3);
   compare("*%5.g*", 3.0);
   compare("*%5.g*", .999999E-4);
   compare("*%5.g*", 1.0E-4);
   compare("*%5.g*", .99E-3);
   compare("*%5.g*", 3333.0);
   compare("*%5.g*", 0.01);

   compare("*%5.2g*", 3.3);
   compare("*%5.2g*", 3.0);
   compare("*%5.2g*", .999999E-4);
   compare("*%5.2g*", .99E-3);
   compare("*%5.2g*", 3333.0);
   compare("*%5.2g*", 0.01);

   return 0;
}