source: tests/math1.cfa @ d62806c

ADTarm-ehast-experimentalenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprpthread-emulationqualifiedEnum
Last change on this file since d62806c was 1201d54, checked in by Peter A. Buhr <pabuhr@…>, 5 years ago

remove spurious empty argument

  • Property mode set to 100644
File size: 2.5 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// math1.cfa --
8//
9// Author           : Peter A. Buhr
10// Created On       : Fri Apr 22 14:59:21 2016
11// Last Modified By : Peter A. Buhr
12// Last Modified On : Sun Jul 14 10:16:45 2019
13// Update Count     : 112
14//
15
16#include <fstream.hfa>
17#include <math.hfa>
18
19int main( void ) {
20        float f;
21        double d;
22        long double l;
23
24        sout | "fmod:" | 5.0F % -2.0F | fmod( 5.0F, -2.0F ) | 5.0D % -2.0D | nonl;
25        sout | fmod( 5.0D, -2.0D ) | 5.0L % -2.0L | fmod( 5.0L, -2.0L );
26        sout | "remainder:" | remainder( 2.0F, 3.0F ) | remainder( 2.0D, 3.0D ) | remainder( 2.0L, 3.0L );
27        int quot;
28        f = remquo( 3.6F, 0.5F, &quot );
29        sout | "remquo:" | quot | f | nonl;
30        d = remquo( 3.6D, 0.5F, &quot );
31        sout | quot | d | nonl;
32        l = remquo( 3.6L, 0.5L, &quot );
33        sout | quot | l;
34        sout | "div:" | div( 3.6F, 0.5F ) | div( 3.6D, 0.5D ) | div( 3.6L, 0.5L );
35        sout | "fma:" | fma( 3.0F, -1.0F, 1.0F ) | fma( 3.0D, -1.0D, 1.0D ) | fma( 3.0L, -1.0L, 1.0L );
36        sout | "fdim:" | fdim( 1.0F, -1.0F ) | fdim( 1.0D, -1.0D ) | fdim( 1.0L, -1.0L );
37        sout | "nan:" | (float)nan( "" ) | (double)nan( "" ) | (long double)nan( "" );
38
39        //---------------------- Exponential ----------------------
40
41        sout | "exp:" | exp( 1.0F ) | exp( 1.0D ) | exp( 1.0L ) | nonl;
42        sout | exp( 1.0F+1.0FI ) | exp( 1.0D+1.0DI ) | exp( 1.0DL+1.0LI );
43        sout | "exp2:" | exp2( 1.0F ) | exp2( 1.0D ) | exp2( 1.0L );
44        sout | "expm1:" | expm1( 1.0F ) | expm1( 1.0D ) | expm1( 1.0L );
45        sout | "pow:" | pow( 1.0F, 1.0F ) | pow( 1.0D, 1.0D ) | pow( 1.0L, 1.0L ) | nonl;
46        sout | pow( 1.0F+1.0FI, 1.0F+1.0FI ) | pow( 1.0D+1.0DI, 1.0D+1.0DI ) | pow( 1.5DL+1.5LI, 1.5DL+1.5LI );
47
48        int b = 4;
49        unsigned int e = 2;
50    b \= e;
51    sout | b | "\\" | e | "= " | b \ e;
52    sout | 'a' \ 3 | 2 \ 8 | 4 \ 3 | -4 \ 3 | 4 \ -3 | -4 \ -3;
53        sout | 4.0 \ -3 | -4.0 \ -3 | 4.0 \ 2.1 | (1.0f+2.0fi) \ (3.0f+2.0fi);
54        sout | 4 \ -3 | -4 \ -3 | 4.0 \ 2.1 | (1.0f+2.0fi) \ (3.0f+2.0fi);
55
56        struct S { int i; };
57        double ?*?( double d, S s ) { return d * s.i; }
58        double ?/?( double d, S s ) { return d / s.i; }
59        S ?\?( S s, unsigned long y ) { return (S){ s.i \ y }; }
60        ofstream & ?|?( ofstream & os, S s ) { return os | s.i; }
61        void ?|?( ofstream & os, S s ) { (ofstream &)(os | s); ends( os ); }
62        S s = { 4 };
63        S x = s \ 2;
64        sout | x;
65        sout | s.i | s \ 2u;
66} // main
67
68// Local Variables: //
69// tab-width: 4 //
70// compile-command: "cfa math1.cfa" //
71// End: //
Note: See TracBrowser for help on using the repository browser.