mathtest.C |
#ifdef __FreeBSD__ #include <iostream.h> #else #include <iostream> using namespace std; #endif #include <cerrno> #include <cmath> int main() { double x; cin >> x; x = abs(x); x = ceil(x); x = floor(x); x = sqrt(x); x = pow(x, x); x = pow(x, 3); x = cos(x); x = sin(x); x = tan(x); x = acos(x); x = asin(x); x = atan(x); x = atan2(x, x); x = sinh(x); x = cosh(x); x = tanh(x); x = exp(x); x = log(x); x = log10(x); cout << x << endl; // 次の文で FreeBSD 3.4 では Floating exception 発生! x = sqrt(-1); if (errno == EDOM) cerr << "sqrt()" << endl; x = pow(1e+300, 2); if (errno == ERANGE) cerr << "pow()" << endl; } |