Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Стандартом не определено, является ли char знаковым или беззнаковым.
- Можешь попробовать вместо std::string использовать std::basic_string<unsigned char> тогда символы будут представлены точно беззнаковыми значениями.
- Можешь сделать так:
- >> unsigned char uc = static_cast<unsigned char>(s\[i\]);
- >> if (arr\[uc\]) { ... }
- Насколько я понимаю, исходя из этого:
- >> If the destination type is unsigned, the resulting value is the least unsigned integer congruent to the source integer (modulo 2^n where n is the number of bits used to represent the unsigned type). [ Note: In a two’s complement representation, this conversion is conceptual and there is no change in the bit pattern (if there is no truncation)].
- преобразования из signed в unsigned тип обязано происходить БЕЗ ОТБРАСЫВАНИЯ знакового бита, если объем памяти занимаемыми исходным значением и переменной-назначением одинаков.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement