Skip to content

Commit

Permalink
more
Browse files Browse the repository at this point in the history
  • Loading branch information
albertz committed Apr 6, 2016
1 parent 89e09a8 commit bcd31c0
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
8 changes: 8 additions & 0 deletions test_g1.cpp
@@ -0,0 +1,8 @@
#include <iostream>

int main() {
using namespace std;
cout << "Hello world" << endl;
return 0;
}

45 changes: 45 additions & 0 deletions test_isinf.cpp
@@ -0,0 +1,45 @@
#include <iostream>
#include <cmath>
#include <stdint.h>
#include <limits>

using std::cout;
using std::endl;

static bool my_isnan1(double val) {
union { double f; uint64_t x; } u = { val };
return (u.x << 1) > 0x7ff0000000000000u;
}

static bool my_isnan2(double val) {
return val != val;
}

static bool my_isnan3(double val) {
volatile double a = val;
return a != a;
}

static void check_nan(double val) {
cout << "value: " << val << endl;
cout << std::isnan(val) << endl;
cout << ::isnan(val) << endl;
cout << __isnan(val) << endl;
cout << my_isnan1(val) << endl;
cout << my_isnan2(val) << endl;
cout << my_isnan3(val) << endl;
}

int main() {
double a = std::log(0.0);
cout << std::isinf(a) << endl;

double b = std::sqrt(-1.0);
check_nan(b);

double c = std::numeric_limits<double>::quiet_NaN();
check_nan(c);

return 0;
}

0 comments on commit bcd31c0

Please sign in to comment.