| 38 | const int MathLib::bigint_bits = 64; |
| 39 | |
| 40 | MathLib::value::value(const std::string &s) |
| 41 | { |
| 42 | if (MathLib::isFloat(s)) { |
| 43 | mType = MathLib::value::Type::FLOAT; |
| 44 | mDoubleValue = MathLib::toDoubleNumber(s); |
| 45 | return; |
| 46 | } |
| 47 | |
| 48 | if (!MathLib::isInt(s)) |
| 49 | throw InternalError(nullptr, "Invalid value: " + s); |
| 50 | |
| 51 | mType = MathLib::value::Type::INT; |
| 52 | mIntValue = MathLib::toBigNumber(s); |
| 53 | |
| 54 | if (isIntHex(s) && mIntValue < 0) |
| 55 | mIsUnsigned = true; |
| 56 | |
| 57 | // read suffix |
| 58 | if (s.size() >= 2U) { |
| 59 | for (std::size_t i = s.size() - 1U; i > 0U; --i) { |
| 60 | const char c = s[i]; |
| 61 | if (c == 'u' || c == 'U') |
| 62 | mIsUnsigned = true; |
| 63 | else if (c == 'l' || c == 'L') { |
| 64 | if (mType == MathLib::value::Type::INT) |
| 65 | mType = MathLib::value::Type::LONG; |
| 66 | else if (mType == MathLib::value::Type::LONG) |
| 67 | mType = MathLib::value::Type::LONGLONG; |
| 68 | } else if (i > 2U && c == '4' && s[i-1] == '6' && s[i-2] == 'i') |
| 69 | mType = MathLib::value::Type::LONGLONG; |
| 70 | } |
| 71 | } |
| 72 | } |
| 73 | |
| 74 | std::string MathLib::value::str() const |
| 75 | { |
no test coverage detected