astyle formatting

[ci skip]
This commit is contained in:
Daniel Marjamäki 2014-04-15 06:32:25 +02:00
parent 4b6164087e
commit 28751c8ad0
2 changed files with 77 additions and 75 deletions

View File

@ -25,98 +25,100 @@
#include <cctype>
#include <limits>
MathLib::biguint MathLib::toULongNumber(const std::string & str) {
// hexadecimal numbers:
if (isHex(str)) {
if (str[0] == '-') {
biguint ret = 0;
std::istringstream istr(str);
istr >> std::hex >> ret;
return ret;
} else {
unsigned long long ret = 0;
std::istringstream istr(str);
istr >> std::hex >> ret;
return (biguint)ret;
}
}
// octal numbers:
if (isOct(str)) {
MathLib::biguint MathLib::toULongNumber(const std::string & str)
{
// hexadecimal numbers:
if (isHex(str)) {
if (str[0] == '-') {
biguint ret = 0;
std::istringstream istr(str);
istr >> std::oct >> ret;
istr >> std::hex >> ret;
return ret;
} else {
unsigned long long ret = 0;
std::istringstream istr(str);
istr >> std::hex >> ret;
return (biguint)ret;
}
}
// binary numbers:
if (isBin(str)) {
biguint ret = 0;
for (std::string::size_type i = str[0] == '0'?2:3; i < str.length(); i++) {
ret <<= 1;
if (str[i] == '1')
ret |= 1;
}
/* if (str[0] == '-')
ret = -ret; */
return ret;
}
if (isFloat(str)) {
return static_cast<biguint>(std::atof(str.c_str()));
}
// octal numbers:
if (isOct(str)) {
biguint ret = 0;
std::istringstream istr(str);
istr >> ret;
istr >> std::oct >> ret;
return ret;
}
}
MathLib::bigint MathLib::toLongNumber(const std::string & str) {
// hexadecimal numbers:
if (isHex(str)) {
if (str[0] == '-') {
bigint ret = 0;
std::istringstream istr(str);
istr >> std::hex >> ret;
return ret;
} else {
unsigned long long ret = 0;
std::istringstream istr(str);
istr >> std::hex >> ret;
return (bigint)ret;
}
// binary numbers:
if (isBin(str)) {
biguint ret = 0;
for (std::string::size_type i = str[0] == '0'?2:3; i < str.length(); i++) {
ret <<= 1;
if (str[i] == '1')
ret |= 1;
}
/* if (str[0] == '-')
ret = -ret; */
return ret;
}
// octal numbers:
if (isOct(str)) {
if (isFloat(str)) {
return static_cast<biguint>(std::atof(str.c_str()));
}
biguint ret = 0;
std::istringstream istr(str);
istr >> ret;
return ret;
}
MathLib::bigint MathLib::toLongNumber(const std::string & str)
{
// hexadecimal numbers:
if (isHex(str)) {
if (str[0] == '-') {
bigint ret = 0;
std::istringstream istr(str);
istr >> std::oct >> ret;
istr >> std::hex >> ret;
return ret;
} else {
unsigned long long ret = 0;
std::istringstream istr(str);
istr >> std::hex >> ret;
return (bigint)ret;
}
}
// binary numbers:
if (isBin(str)) {
bigint ret = 0;
for (std::string::size_type i = str[0] == '0'?2:3; i < str.length(); i++) {
ret <<= 1;
if (str[i] == '1')
ret |= 1;
}
if (str[0] == '-')
ret = -ret;
return ret;
}
if (isFloat(str)) {
return static_cast<bigint>(std::atof(str.c_str()));
}
// octal numbers:
if (isOct(str)) {
bigint ret = 0;
std::istringstream istr(str);
istr >> ret;
istr >> std::oct >> ret;
return ret;
}
// binary numbers:
if (isBin(str)) {
bigint ret = 0;
for (std::string::size_type i = str[0] == '0'?2:3; i < str.length(); i++) {
ret <<= 1;
if (str[i] == '1')
ret |= 1;
}
if (str[0] == '-')
ret = -ret;
return ret;
}
if (isFloat(str)) {
return static_cast<bigint>(std::atof(str.c_str()));
}
bigint ret = 0;
std::istringstream istr(str);
istr >> ret;
return ret;
}

View File

@ -804,7 +804,7 @@ static std::string ShiftInt(const char cop, const Token* left, const Token* righ
{
if (cop == '&' || cop == '|' || cop == '^')
return MathLib::calculate(left->str(), right->str(), cop);
const MathLib::bigint leftInt=MathLib::toLongNumber(left->str());
const MathLib::bigint rightInt=MathLib::toLongNumber(right->str());
if (cop == '<') {
@ -820,7 +820,7 @@ static std::string ShiftUInt(const char cop, const Token* left, const Token* rig
{
if (cop == '&' || cop == '|' || cop == '^')
return MathLib::calculate(left->str(), right->str(), cop);
const MathLib::biguint leftInt=MathLib::toULongNumber(left->str());
const MathLib::biguint rightInt=MathLib::toULongNumber(right->str());
if (cop == '<') {