source: tests/math4.cfa @ f090750

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

add auto newline to sout, change endl to nl

  • Property mode set to 100644
File size: 2.8 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// math4.cfa --
8//
9// Author           : Peter A. Buhr
10// Created On       : Thu May 24 20:56:54 2018
11// Last Modified By : Peter A. Buhr
12// Last Modified On : Tue Dec  4 18:15:01 2018
13// Update Count     : 4
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        //---------------------- Nearest Integer ----------------------
25
26        sout | "floor:" | floor( 1.2F ) | floor( 1.2D ) | floor( 1.2L );
27        sout | "ceil:" | ceil( 1.6F ) | ceil( 1.6D ) | ceil( 1.6L );
28        sout | "trunc:" | trunc( 3.5F ) | trunc( 3.5D ) | trunc( 3.5L );
29        sout | "rint:" | (float)rint( 1.5F ) | (double)rint( 1.5D ) | (long double)rint( 1.5L );
30        sout | "rint:" | (long int)rint( 1.5F ) | (long int)rint( 1.5D ) | (long int)rint( 1.5L );
31        sout | "rint:" | (long long int)rint( 1.5F ) | (long long int)rint( 1.5D ) | (long long int)rint( 1.5L );
32        sout | "lrint:" | lrint( 1.5F ) | lrint( 1.5D ) | lrint( 1.5L );
33        sout | "llrint:" | llrint( 1.5F ) | llrint( 1.5D ) | llrint( 1.5L );
34        sout | "nearbyint:" | nearbyint( 3.5F ) | nearbyint( 3.5D ) | nearbyint( 3.5L );
35        sout | "round:" | (float)round( 1.5F ) | (double)round( 1.5D ) | (long double)round( 1.5L );
36        sout | "round:" | (long int)round( 1.5F ) | (long int)round( 1.5D ) | (long int)round( 1.5L );
37        sout | "round:" | (long long int)round( 1.5F ) | (long long int)round( 1.5D ) | (long long int)round( 1.5L );
38        sout | "lround:" | lround( 1.5F ) | lround( 1.5D ) | lround( 1.5L );
39        sout | "llround:" | llround( 1.5F ) | llround( 1.5D ) | llround( 1.5L );
40
41        //---------------------- Manipulation ----------------------
42
43        sout | "copysign:" | copysign( 1.0F, -1.0F ) | copysign( 1.0D, -1.0D ) | copysign( 1.0L, -1.0L );
44        int exp;
45        f = frexp( 4.0F, &exp );
46        sout | "frexp:" | f | exp | nonl;
47        d = frexp( 4.0D, &exp );
48        sout | d | exp | nonl;
49        l = frexp( 4.0L, &exp );
50        sout | l | exp;
51        sout | "ldexp:" | ldexp( 2.0F, 2 ) | ldexp( 2.0D, 2 ) | ldexp( 2.0L, 2 );
52        float fi;
53        double di;
54        long double ldi;
55        f = modf( 2.3F, &fi );
56        sout | "modf:" | fi | f | nonl;
57        d = modf( 2.3D, &di );
58        sout | di | d | nonl;
59        l = modf( 2.3L, &ldi );
60        sout | ldi | l;
61        sout | "modf:" | modf( 2.3F ) | modf( 2.3D ) | modf( 2.3L );
62        sout | "nextafter:" | nextafter( 2.0F, 3.0F ) | nextafter( 2.0D, 3.0D ) | nextafter( 2.0L, 3.0L );
63        sout | "nexttoward:" | nexttoward( 2.0F, 3.0F ) | nexttoward( 2.0D, 3.0D ) | nexttoward( 2.0L, 3.0L );
64
65        sout | "scalbn:" | scalbn( 2.0F, 3 ) | scalbn( 2.0D, 3 ) | scalbn( 2.0L, 3 );
66        sout | "scalbln:" | scalbln( 2.0F, 3L ) | scalbln( 2.0D, 3L ) | scalbln( 2.0L, 3L );
67} // main
68
69// Local Variables: //
70// tab-width: 4 //
71// compile-command: "cfa math3.cfa" //
72// End: //
Note: See TracBrowser for help on using the repository browser.