X-Git-Url: https://git.ucc.asn.au/?p=ipdf%2Fcode.git;a=blobdiff_plain;f=src%2Ftests%2Fparanoidcalculator.cpp;h=eb30860cc578041882c2b9650646bebfc86b82aa;hp=9c5a88a3edaa396040188d5131e6ca5121598221;hb=888817a67a9d840be66b52811b01eb77f10ff3e6;hpb=dfba002efc3b5f126ddb69e63b9a7dafdd9eacda;ds=sidebyside diff --git a/src/tests/paranoidcalculator.cpp b/src/tests/paranoidcalculator.cpp index 9c5a88a..eb30860 100644 --- a/src/tests/paranoidcalculator.cpp +++ b/src/tests/paranoidcalculator.cpp @@ -17,17 +17,21 @@ int main(int argc, char ** argv) Debug("FLT_MAX = %.40f", FLT_MAX); Debug("FLT_MIN = %.40f", FLT_MIN); Debug("FLT_EPSILON = %.40f", FLT_EPSILON); - - ParanoidNumber a("0.3"); - Debug("start at {%s} = %lf", a.Str().c_str(), a.ToDouble()); - cout << "0.3 "; - float fa = 0.3; - double da = 0.3; + Debug("Sizeof ParanoidNumber::digit_t is %u", sizeof(ParanoidNumber::digit_t)); + Debug("Sizeof ParanoidNumber is %u", sizeof(ParanoidNumber)); + Debug("Sizeof double is %u", sizeof(double)); + Debug("Sizeof ParanoidNumber* %u", sizeof(ParanoidNumber*)); + + string token(""); + cin >> token; + ParanoidNumber a(token.c_str()); + double da = a.ToDouble(); + float fa = da; while (cin.good()) { char op; cin >> op; - string token(""); + token = ""; for (char c = cin.peek(); cin.good() && !iswspace(c); c = cin.peek()) { if (c == '+' || c == '-' || c == '*' || c == '/') @@ -68,6 +72,8 @@ int main(int argc, char ** argv) Debug("a is: %s", a.Str().c_str()); Debug("a as double: %.40f\n", a.ToDouble()); + Debug("a as float: %.40f\n", a.ToFloat()); + Debug("a as int64_t: %ld\n", a.Convert()); Debug("floats give: %.40f\n", fa); Debug("double gives: %.40f\n", da);