Esempio n. 1
0
int main()
{
  testFloat();
  testDouble();

  return 0;
}
Esempio n. 2
0
int main(int argc, char *argv[]) {

    decContextTestEndian(0);    // warn if DECLITEND is wrong

    testFloat();
    testDouble();
    testDecDouble();
    testDecQuad();

    return 0;
}
Esempio n. 3
0
    void test() {
        std::cout << "Testing float vs double ..." << std::endl;
        
        auto d = 0.0;
        auto time0 = getTime();
        d += testDouble(d);
        auto time1 = getTime();
        std::cout << '\t' << "Double " << diffclock(time1, time0) << std::endl;

        auto f = 0.0f;
        auto time2 = getTime();
        f += testFloat(d);
        auto time3 = getTime();
        
        std::cout << '\t' << "Float " << diffclock(time3, time2) << std::endl;
        std::cout << "\n **** \n\n";
    }
Esempio n. 4
0
 void test() {
     std::cout << "Testing float vs double ..." << std::endl;
     
     auto d = 0.0;
     
     auto test0 = [&] {
         d += testDouble(d);
     };
     
     auto f = 0.0f;
     auto test1 = [&] {
         f += testFloat(d);
     };
     
     ADD_BENCHMARK("FloatVSDouble \t Double", test0);
     ADD_BENCHMARK("FloatVSDouble \t Float", test1);
     
     benchpress::run_benchmarks(benchpress::options());
     
 }
Esempio n. 5
0
bool dtoaUnitTest()
{
	std::cout << "dtoaUnitTest()" << std::endl;
	std::cout << std::endl;

	testDouble(std::numeric_limits<double>::infinity(),"INF");
	testDouble(-std::numeric_limits<double>::infinity(),"-INF");
	testDouble(std::numeric_limits<double>::quiet_NaN(),"NaN");
	testDouble(0,                 "0");
	testDouble(1,                 "1");
	testDouble(1.0,               "1");
	testDouble(1.00001,           "1.00001");
	testDouble(1.00001e7,         "1.00001e7");
	testDouble(1.234567,          "1.234567");
	testDouble(123456,            "123456");
	testDouble(1234567,           "1.23457e6");
	testDouble(1234567e23,        "1.23457e29");
	testDouble(1234567e-23,       "1.23457e-17");
	testDouble(123456.789,        "123456.8");

	std::cout << std::endl;
	std::cout << std::endl;

	testDouble(-1,                 "-1");
	testDouble(-1.0,               "-1");
	testDouble(-1.00001,           "-1.00001");
	testDouble(-1.00001e7,         "-1.00001e7");
	testDouble(-123456,            "-123456");
	testDouble(-1234567,           "-1.23457e6");
	testDouble(-1234567e23,        "-1.23457e29");
	testDouble(-1234567e-23,       "-1.23457e-17");
	testDouble(-123456.789,        "-123456.8");

	std::cout << std::endl;
	std::cout << std::endl;

	testDouble(999999,             "999999");
	testDouble(999999.9,           "10e5");
	testDouble(0.0001,             "10e-5");
	testDouble(0.00010006,         "1.0006e-4");
	testDouble(0.000098,           "9.8e-5");

	std::cout << std::endl;
	std::cout << std::endl;

	testDouble(-999999,            "-999999");
	testDouble(-999999.9,          "-10e5");
	testDouble(-0.0001,            "-10e-5");
	testDouble(-0.000098,          "-9.8e-5");

	std::cout << std::endl;
	std::cout << std::endl;

	testDouble(0.00001,             "10e-6");
	testDouble(0.0001,              "10e-5");
	testDouble(0.001,               "10e-4");
	testDouble(0.01,                "0.01");
	testDouble(0.1,                 "0.1");
	testDouble(1,                   "1");
	testDouble(1,                   "1");
	testDouble(10,                  "10");
	testDouble(100,                 "100");
	testDouble(1000,                "1000");
	testDouble(10000,               "10000");
	testDouble(100000,              "100000");
	testDouble(1000000,             "1e6");


	std::cout << std::endl;
	std::cout << "double precision" << std::endl;
	testDouble(123456789012345678,          "1.234567890123457e17", true);
	testDouble(1.23456789012345678,          "1.234567890123457", true);
	testDouble(0.00000000000000000000000023456789012345678,          "2.345678901234568e-25", true);
	testDouble(0.00000000000000000000000000000000000000000000000023456789012345678,          "2.345678901234568e-49", true);
	testDouble(0.9999999999999999,          "0.9999999999999998", true);

	std::cout << std::endl;
	std::cout << std::endl;

	return errroCount == 0;
}