ADTast-experimentalenumpthread-emulationqualifiedEnum
Last change
on this file since 51239d1b was
5ea5b28,
checked in by Peter A. Buhr <pabuhr@…>, 6 years ago
|
update iostream
|
-
Property mode set to
100644
|
File size:
2.2 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.cfa -- |
---|
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 Dec 20 22:41:47 2018 |
---|
13 | // Update Count : 559 |
---|
14 | // |
---|
15 | |
---|
16 | // NOTE: UBUNTU DOES NOT SUPPORT GMP MULTILIB, SO ONLY 64-BIT GMP IS TESTED. |
---|
17 | |
---|
18 | #include <gmp.hfa> |
---|
19 | |
---|
20 | int main( void ) { |
---|
21 | sout | "constructors"; |
---|
22 | short int si = 3; |
---|
23 | Int x = { "50000000000000000000" }, y = { si }, z = x + y; |
---|
24 | sout | x | y | z; |
---|
25 | sout | "x:" | x | "y:" | y | "z:" | z; |
---|
26 | |
---|
27 | sout | "conversions"; |
---|
28 | y = 'a'; |
---|
29 | sout | "y:" | y; |
---|
30 | y = "12345678901234567890123456789"; |
---|
31 | sout | "y:" | y; |
---|
32 | y = 100`mp + 100`mp; |
---|
33 | sout | "y:" | y; |
---|
34 | y = -200u`mp + -200u`mp; |
---|
35 | sout | "y:" | y; |
---|
36 | y = "12345678901234567890123456789"`mp + "12345678901234567890123456789"`mp; |
---|
37 | sout | "y:" | y; |
---|
38 | y = si; |
---|
39 | sout | "y:" | y; |
---|
40 | y = -3; |
---|
41 | sout | "y:" | y; |
---|
42 | y += 7; |
---|
43 | sout | "y:" | y; |
---|
44 | y -= 1; |
---|
45 | sout | "y:" | y; |
---|
46 | int b; |
---|
47 | b = y; |
---|
48 | si = y; |
---|
49 | sout | "y:" | y | "b:" | b | "si:" | si; |
---|
50 | |
---|
51 | sout | "comparison"; |
---|
52 | sout | x == x; |
---|
53 | sout | x != x; |
---|
54 | sout | x < x; |
---|
55 | sout | x <= x; |
---|
56 | sout | x > x; |
---|
57 | sout | x >= x; |
---|
58 | |
---|
59 | sout | "arithmetic"; |
---|
60 | z = x + y + z; |
---|
61 | sout | "z:" | z; |
---|
62 | z = z = x; |
---|
63 | sout | "z:" | z; |
---|
64 | z = x - y - z; |
---|
65 | sout | "z:" | z; |
---|
66 | z = x * y * z; |
---|
67 | sout | "z:" | z; |
---|
68 | z = x * 3; |
---|
69 | sout | "z:" | z; |
---|
70 | z = 3 * x; |
---|
71 | sout | "z:" | z; |
---|
72 | z = x / 3; |
---|
73 | sout | "z:" | z; |
---|
74 | sout | div( x, 3 ) | x / 3 | "," | x % 3; |
---|
75 | [ x, y ] = div( x, 3 ); |
---|
76 | sout | "x:" | x | "y:" | y; |
---|
77 | |
---|
78 | sout | nl; |
---|
79 | |
---|
80 | sin | x | y | z; |
---|
81 | sout | x | y | z; |
---|
82 | |
---|
83 | sout | nl; |
---|
84 | |
---|
85 | sout | "Fibonacci Numbers"; |
---|
86 | Int fn, fn1, fn2; |
---|
87 | fn = (Int){0}; fn1 = fn; // 1st case |
---|
88 | sout | (int)0 | fn; |
---|
89 | fn = 1; fn2 = fn1; fn1 = fn; // 2nd case |
---|
90 | sout | 1 | fn; |
---|
91 | for ( i; 2u ~= 200 ) { |
---|
92 | fn = fn1 + fn2; fn2 = fn1; fn1 = fn; // general case |
---|
93 | sout | i | fn; |
---|
94 | } // for |
---|
95 | |
---|
96 | sout | nl; |
---|
97 | |
---|
98 | sout | "Factorial Numbers"; |
---|
99 | Int fact = 1; // 1st case |
---|
100 | sout | (int)0 | fact; |
---|
101 | for ( i; 1u ~= 40u ) { |
---|
102 | fact *= i; // general case |
---|
103 | sout | i | fact; |
---|
104 | } // for |
---|
105 | } // main |
---|
106 | |
---|
107 | // Local Variables: // |
---|
108 | // tab-width: 4 // |
---|
109 | // compile-command: "cfa gmp.cfa -lgmp" // |
---|
110 | // End: // |
---|
Note: See
TracBrowser
for help on using the repository browser.