We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents b6ace05 + 28a2e1e commit 6bbef98Copy full SHA for 6bbef98
library/core/src/fmt/num.rs
@@ -678,8 +678,8 @@ impl fmt::Display for i128 {
678
/// It also has to handle 1 last item, as 10^40 > 2^128 > 10^39, whereas
679
/// 10^20 > 2^64 > 10^19.
680
fn fmt_u128(n: u128, is_nonnegative: bool, f: &mut fmt::Formatter<'_>) -> fmt::Result {
681
- // 2^128 is about 3*10^38, so 39 gives an extra byte of space
682
- let mut buf = [MaybeUninit::<u8>::uninit(); 39];
+ const MAX_DEC_N: usize = u128::MAX.ilog(10) as usize + 1;
+ let mut buf = [MaybeUninit::<u8>::uninit(); MAX_DEC_N];
683
let mut curr = buf.len();
684
685
let (n, rem) = udiv_1e19(n);
0 commit comments