| 72 | } |
| 73 | |
| 74 | std::string MathLib::value::str() const |
| 75 | { |
| 76 | std::ostringstream ostr; |
| 77 | if (mType == MathLib::value::Type::FLOAT) { |
| 78 | if (std::isnan(mDoubleValue)) |
| 79 | return "nan.0"; |
| 80 | if (std::isinf(mDoubleValue)) |
| 81 | return (mDoubleValue > 0) ? "inf.0" : "-inf.0"; |
| 82 | |
| 83 | ostr.precision(9); |
| 84 | ostr << std::fixed << mDoubleValue; |
| 85 | |
| 86 | // remove trailing zeros |
| 87 | std::string ret(ostr.str()); |
| 88 | std::string::size_type pos = ret.size() - 1U; |
| 89 | while (ret[pos] == '0') |
| 90 | pos--; |
| 91 | if (ret[pos] == '.') |
| 92 | ++pos; |
| 93 | |
| 94 | return ret.substr(0, pos+1); |
| 95 | } |
| 96 | |
| 97 | if (mIsUnsigned) |
| 98 | ostr << static_cast<biguint>(mIntValue) << "U"; |
| 99 | else |
| 100 | ostr << mIntValue; |
| 101 | if (mType == MathLib::value::Type::LONG) |
| 102 | ostr << "L"; |
| 103 | else if (mType == MathLib::value::Type::LONGLONG) |
| 104 | ostr << "LL"; |
| 105 | return ostr.str(); |
| 106 | } |
| 107 | |
| 108 | void MathLib::value::promote(const MathLib::value &v) |
| 109 | { |
no test coverage detected