Skip to content

Commit 12fe933

Browse files
committed
Fix zero constant output
1 parent 1e86b5e commit 12fe933

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

include/slimcpplib/long_io.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ inline std::basic_ostream<char_t, traits_t>& operator<<(std::basic_ostream<char_
8484
base = 16;
8585

8686
constexpr uint_t max_digits = (bit_count_v<long_uint_t> + 2) / 3;
87-
const uint_t digit_count = static_cast<uint_t>(std::ceil((bit_count_v<long_uint_t> - nlz(value)) * std::log10(2) / std::log10(base)));
87+
const uint_t digit_count = std::max<uint_t>(1, static_cast<uint_t>(std::ceil((bit_count_v<long_uint_t> - nlz(value)) * std::log10(2) / std::log10(base))));
8888
const bool uppercase = (stream.flags() & std::ios::uppercase) != 0;
8989
std::array<char_t, max_digits> output;
9090

0 commit comments

Comments
 (0)