source: tests/math4.cfa @ 0da5cd5

ADTarm-ehast-experimentalenumforall-pointer-decayjacob/cs343-translationnew-astnew-ast-unique-exprpthread-emulationqualifiedEnum
Last change on this file since 0da5cd5 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
RevLine 
[73abe95]1//
[ef3403c6]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.
[73abe95]6//
[dc8511c]7// math4.cfa --
[73abe95]8//
[ef3403c6]9// Author           : Peter A. Buhr
10// Created On       : Thu May 24 20:56:54 2018
11// Last Modified By : Peter A. Buhr
[200fcb3]12// Last Modified On : Tue Dec  4 18:15:01 2018
13// Update Count     : 4
[73abe95]14//
[ef3403c6]15
[73abe95]16#include <fstream.hfa>
17#include <math.hfa>
[ef3403c6]18
19int main( void ) {
20        float f;
21        double d;
22        long double l;
23
24        //---------------------- Nearest Integer ----------------------
25
[200fcb3]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 );
[ef3403c6]40
41        //---------------------- Manipulation ----------------------
42
[200fcb3]43        sout | "copysign:" | copysign( 1.0F, -1.0F ) | copysign( 1.0D, -1.0D ) | copysign( 1.0L, -1.0L );
[ef3403c6]44        int exp;
45        f = frexp( 4.0F, &exp );
[200fcb3]46        sout | "frexp:" | f | exp | nonl;
[ef3403c6]47        d = frexp( 4.0D, &exp );
[200fcb3]48        sout | d | exp | nonl;
[ef3403c6]49        l = frexp( 4.0L, &exp );
[200fcb3]50        sout | l | exp;
51        sout | "ldexp:" | ldexp( 2.0F, 2 ) | ldexp( 2.0D, 2 ) | ldexp( 2.0L, 2 );
[ef3403c6]52        float fi;
53        double di;
54        long double ldi;
55        f = modf( 2.3F, &fi );
[200fcb3]56        sout | "modf:" | fi | f | nonl;
[ef3403c6]57        d = modf( 2.3D, &di );
[200fcb3]58        sout | di | d | nonl;
[ef3403c6]59        l = modf( 2.3L, &ldi );
[200fcb3]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 );
[ef3403c6]64
[200fcb3]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 );
[ef3403c6]67} // main
68
69// Local Variables: //
70// tab-width: 4 //
[dc8511c]71// compile-command: "cfa math3.cfa" //
[ef3403c6]72// End: //
Note: See TracBrowser for help on using the repository browser.