diff --git a/cpp/Platform.Numbers/Bit.h b/cpp/Platform.Numbers/Bit.h index e210a04..310796b 100644 --- a/cpp/Platform.Numbers/Bit.h +++ b/cpp/Platform.Numbers/Bit.h @@ -59,11 +59,11 @@ namespace Platform::Numbers::Bit { if (shift < 0) { - shift = sizeof(T) * 8 + shift; + shift = sizeof(T) * std::numeric_limits::digits + shift; } if (limit < 0) { - limit = sizeof(T) * 8 + limit; + limit = sizeof(T) * std::numeric_limits::digits + limit; } auto sourceMask = ~(std::numeric_limits::max() << limit) & std::numeric_limits::max(); auto targetMask = ~(sourceMask << shift); @@ -75,11 +75,11 @@ namespace Platform::Numbers::Bit { if (shift < 0) { - shift = sizeof(T) * 8 + shift; + shift = sizeof(T) * std::numeric_limits::digits + shift; } if (limit < 0) { - limit = sizeof(T) * 8 + limit; + limit = sizeof(T) * std::numeric_limits::digits + limit; } auto sourceMask = ~(std::numeric_limits::max() << limit) & std::numeric_limits::max(); auto targetMask = sourceMask << shift;