Open alexey-malov opened 8 years ago
if (inStr[i] == '1')
{
if (owerflow)
{
cout << "Error! Result owerflow!" << endl;
return 1;
}
result += multiplier;
}
else
if (inStr[i] != '0')
{
cout << "Invalid argument type!" << endl
<< "Usage: bin2dec.exe <binary number>" << endl;
return 1;
}
for (int i = inStrSize - 1; i >= 0; --i)
1>c:\teaching\2016\ips\lihachev\oop2016\bin2dec\main.cpp(22): warning C4267: 'initializing': conversion from 'size_t' to 'int', possible loss of data
{
auto inStrSize = binString.size();
if (inStrSize > MAX_SIZE_LENGTH)
{
errorMessage = errorMessage.append("Invalid arguments length!\nMax numbers length must be ")
.append(to_string(MAX_SIZE_LENGTH)).append(", but found ").append(to_string(inStrSize));
return ERROR_STATE;
}
int ERROR_STATE = -1;
int MAX_SIZE_LENGTH = 32;
int Bin2dec(string const & binString, unsigned long int & result, string & errorMessage)
{
auto inStrSize = binString.size();
if (inStrSize > MAX_SIZE_LENGTH)
sizeof(type) * CHAR_BIT