Fixed #4295 (False positive: Expression '(X & 0xFF00000000000000LL)==0xa00000000000000' always evaluates to false (64-bit value))

This commit is contained in:
Daniel Marjamäki 2012-11-27 17:37:49 +01:00
parent ea9f0718b0
commit 4e92f8dfcd
2 changed files with 15 additions and 4 deletions

View File

@ -31,10 +31,17 @@ MathLib::bigint MathLib::toLongNumber(const std::string &str)
{ {
// hexadecimal numbers: // hexadecimal numbers:
if (isHex(str)) { if (isHex(str)) {
bigint ret = 0; if (str[0] == '-') {
std::istringstream istr(str); bigint ret = 0;
istr >> std::hex >> ret; std::istringstream istr(str);
return ret; istr >> std::hex >> ret;
return ret;
} else {
unsigned long long ret = 0;
std::istringstream istr(str);
istr >> std::hex >> ret;
return (bigint)ret;
}
} }
// octal numbers: // octal numbers:

View File

@ -185,6 +185,10 @@ private:
ASSERT_EQUALS(100 , MathLib::toLongNumber("+10.0E+1")); ASSERT_EQUALS(100 , MathLib::toLongNumber("+10.0E+1"));
ASSERT_EQUALS(-1 , MathLib::toLongNumber("-10.0E-1")); ASSERT_EQUALS(-1 , MathLib::toLongNumber("-10.0E-1"));
// from long long
ASSERT_EQUALS(0xFF00000000000000LL, MathLib::toLongNumber("0xFF00000000000000LL"));
ASSERT_EQUALS(0x0A00000000000000LL, MathLib::toLongNumber("0x0A00000000000000LL"));
// ----------------- // -----------------
// to double number: // to double number:
// ----------------- // -----------------