source: src/tests/gmp.c @ 1ae39f6e

ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsdeferred_resndemanglerenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newwith_gc
Last change on this file since 1ae39f6e was 1ae39f6e, checked in by Peter A. Buhr <pabuhr@…>, 7 years ago

change gmp to use references, add fstream_test to tests

  • Property mode set to 100644
File size: 2.3 KB
Line 
1//
2// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
3//
4// The contents of this file are covered under the licence agreement in the
5// file "LICENCE" distributed with Cforall.
6//
7// gmp.c --
8//
9// Author           : Peter A. Buhr
10// Created On       : Tue Apr 19 08:55:51 2016
11// Last Modified By : Peter A. Buhr
12// Last Modified On : Thu Aug 24 09:33:26 2017
13// Update Count     : 543
14//
15
16#include <gmp>
17
18int main( void ) {
19        sout | "constructors" | endl;
20        short int si = 3;
21        Int x = { "50000000000000000000" }, y = { si }, z = x + y;
22        sout | x | y | z | endl;
23        sout | "x:" | x | "y:" | y | "z:" | z | endl;
24
25        sout | "conversions" | endl;
26        y = 'a';
27        sout | "y:" | y | endl;
28        y = "12345678901234567890123456789";
29        sout | "y:" | y | endl;
30        y = si;
31        sout | "y:" | y | endl;
32        y = -3;
33        sout | "y:" | y | endl;
34        y += 7;
35        sout | "y:" | y | endl;
36        y -= 1;
37        sout | "y:" | y | endl;
38        int b;
39        b = y;
40        si = y;
41        sout | "y:" | y | "b:" | b | "si:" | si | endl;
42
43        sout | "comparison" | endl;
44        sout | x == x | endl;
45        sout | x != x | endl;
46        sout | x < x | endl;
47        sout | x <= x | endl;
48        sout | x > x | endl;
49        sout | x >= x | endl;
50
51        sout | "arithmetic" | endl;
52        z = x + y + z;
53        sout | "z:" | z | endl;
54        z = z = x;
55        sout | "z:" | z | endl;
56        z = x - y - z;
57        sout | "z:" | z | endl;
58        z = x * y * z;
59        sout | "z:" | z | endl;
60        z = x * 3;
61        sout | "z:" | z | endl;
62        z = 3 * x;
63        sout | "z:" | z | endl;
64        z = x / 3;
65        sout | "z:" | z | endl;
66        sout | div( x, 3 ) | x / 3 | "," | x % 3 | endl;
67        [ x, y ] = div( x, 3 );
68        sout | "x:" | x | "y:" | y | endl;
69
70        sout | endl;
71
72        sin | x | y | z;
73        sout | x | y | z | endl;
74
75        sout | endl;
76
77        sout | "Fibonacci Numbers" | endl;
78        Int fn, fn1, fn2;
79        fn = (Int){0}; fn1 = fn;                                                        // 1st case
80        sout | (int)0 | fn | endl;
81        fn = 1; fn2 = fn1; fn1 = fn;                                            // 2nd case
82        sout | 1 | fn | endl;
83        for ( unsigned int i = 2; i <= 200; i += 1 ) {
84                fn = fn1 + fn2; fn2 = fn1; fn1 = fn;                    // general case
85                sout | i | fn | endl;
86        } // for
87
88        sout | endl;
89
90        sout | "Factorial Numbers" | endl;
91        Int fact;
92        fact = 1;                                                                                       // 1st case
93        sout | (int)0 | fact | endl;
94        for ( unsigned int i = 1; i <= 40; i += 1 ) {
95                fact *= i;                                                                              // general case
96                sout | i | fact | endl;
97        } // for
98} // main
99
100// Local Variables: //
101// tab-width: 4 //
102// compile-command: "cfa gmp.c -lgmp" //
103// End: //
Note: See TracBrowser for help on using the repository browser.