1
0
mirror of synced 2024-11-28 09:30:51 +01:00

bug: Fix binary value in base converter being shifted by one

Fixes #212
This commit is contained in:
WerWolv 2021-03-30 18:38:28 +02:00
parent 6223b26888
commit 356273d71e

View File

@ -195,11 +195,11 @@ namespace hex {
return result;
}
inline std::string toBinaryString(hex::integral auto number) {
inline std::string toBinaryString(hex::unsigned_integral auto number) {
if (number == 0) return "0";
std::string result;
for (u8 bit = hex::bit_width(number); bit > 0; bit--)
for (s16 bit = hex::bit_width(number) - 1; bit >= 0; bit--)
result += (number & (0b1 << bit)) == 0 ? '0' : '1';
return result;