LikhachevAV / OOP2016

0 stars 0 forks source link

Замечания по bin2dec #2

Open alexey-malov opened 8 years ago

alexey-malov commented 8 years ago
alexey-malov commented 8 years ago
alexey-malov commented 8 years ago
alexey-malov commented 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;
        }
alexey-malov commented 8 years ago
    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
alexey-malov commented 8 years ago
{
    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;
    }
alexey-malov commented 8 years ago
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

alexey-malov commented 8 years ago