constexpr HexTable() {
// Default initialize everything to invalid.
for (int i = 0; i < 255; ++i)
- LUT[i] = -1U;
+ LUT[i] = ~0U;
// Initialize `0`-`9`.
for (int i = 0; i < 10; ++i)
LUT['0' + i] = i;
inline bool isDigit(char C) { return C >= '0' && C <= '9'; }
/// Checks if character \p C is a hexadecimal numeric character.
-inline bool isHexDigit(char C) { return hexDigitValue(C) != -1U; }
+inline bool isHexDigit(char C) { return hexDigitValue(C) != ~0U; }
/// Checks if character \p C is a valid letter as classified by "C" locale.
inline bool isAlpha(char C) {
inline bool tryGetHexFromNibbles(char MSB, char LSB, uint8_t &Hex) {
unsigned U1 = hexDigitValue(MSB);
unsigned U2 = hexDigitValue(LSB);
- if (U1 == -1U || U2 == -1U)
+ if (U1 == ~0U || U2 == ~0U)
return false;
Hex = static_cast<uint8_t>((U1 << 4) | U2);
inline std::string itostr(int64_t X) {
if (X < 0)
- return utostr(-static_cast<uint64_t>(X), true);
+ return utostr(static_cast<uint64_t>(1) + ~static_cast<uint64_t>(X), true);
else
return utostr(static_cast<uint64_t>(X));
}
inline int64_t minIntN(int64_t N) {
assert(N > 0 && N <= 64 && "integer width out of range");
- return -(UINT64_C(1)<<(N-1));
+ return UINT64_C(1) + ~(UINT64_C(1) << (N - 1));
}
/// Gets the maximum value for a N-bit signed integer.