[73abe95] | 1 | // |
---|
[0a5b683] | 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 | // math1.cfa -- |
---|
[73abe95] | 8 | // |
---|
[0a5b683] | 9 | // Author : Peter A. Buhr |
---|
| 10 | // Created On : Fri Apr 22 14:59:21 2016 |
---|
| 11 | // Last Modified By : Peter A. Buhr |
---|
[ac1ae2c6] | 12 | // Last Modified On : Wed Dec 12 16:28:49 2018 |
---|
| 13 | // Update Count : 89 |
---|
[73abe95] | 14 | // |
---|
[0a5b683] | 15 | |
---|
[73abe95] | 16 | #include <fstream.hfa> |
---|
| 17 | #include <math.hfa> |
---|
[0a5b683] | 18 | |
---|
| 19 | int main( void ) { |
---|
| 20 | float f; |
---|
| 21 | double d; |
---|
| 22 | long double l; |
---|
| 23 | |
---|
[ac1ae2c6] | 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 ); |
---|
[200fcb3] | 26 | sout | "remainder:" | remainder( 2.0F, 3.0F ) | remainder( 2.0D, 3.0D ) | remainder( 2.0L, 3.0L ); |
---|
[0a5b683] | 27 | int quot; |
---|
| 28 | f = remquo( 3.6F, 0.5F, " ); |
---|
[200fcb3] | 29 | sout | "remquo:" | quot | f | nonl; |
---|
[0a5b683] | 30 | d = remquo( 3.6D, 0.5F, " ); |
---|
[200fcb3] | 31 | sout | quot | d | nonl; |
---|
[0a5b683] | 32 | l = remquo( 3.6L, 0.5L, " ); |
---|
[200fcb3] | 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( "" ); |
---|
[0a5b683] | 38 | |
---|
| 39 | //---------------------- Exponential ---------------------- |
---|
| 40 | |
---|
[ac1ae2c6] | 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 ); |
---|
[200fcb3] | 43 | sout | "exp2:" | exp2( 1.0F ) | exp2( 1.0D ) | exp2( 1.0L ); |
---|
| 44 | sout | "expm1:" | expm1( 1.0F ) | expm1( 1.0D ) | expm1( 1.0L ); |
---|
[ac1ae2c6] | 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 ); |
---|
[0a5b683] | 47 | |
---|
| 48 | int b = 4; |
---|
| 49 | unsigned int e = 2; |
---|
| 50 | b \= e; |
---|
[200fcb3] | 51 | sout | "\\" | b | b \ e; |
---|
[ac1ae2c6] | 52 | sout | "\\" | 'a' \ 3u | 2 \ 8u | 4 \ 3u | -4 \ 3u | nonl; |
---|
| 53 | sout | 4 \ -3 | -4 \ -3 | 4.0 \ 2.1 | (1.0f+2.0fi) \ (3.0f+2.0fi); |
---|
[0a5b683] | 54 | } // main |
---|
| 55 | |
---|
| 56 | // Local Variables: // |
---|
| 57 | // tab-width: 4 // |
---|
[dc8511c] | 58 | // compile-command: "cfa math1.cfa" // |
---|
[0a5b683] | 59 | // End: // |
---|