1
Fork 0

40 -> 39, as ceil(log10(2^128)) == 39

just as ceil(log10(2^64)) == 20
This commit is contained in:
est31 2016-11-28 02:18:34 +01:00
parent 3b34f90bc1
commit c79aba71d5
2 changed files with 3 additions and 1 deletions

View file

@ -211,7 +211,7 @@ macro_rules! impl_Display {
// convert the negative num to positive by summing 1 to it's 2 complement // convert the negative num to positive by summing 1 to it's 2 complement
(!self.$conv_fn()).wrapping_add(1) (!self.$conv_fn()).wrapping_add(1)
}; };
let mut buf: [u8; 40] = unsafe { mem::uninitialized() }; let mut buf: [u8; 39] = unsafe { mem::uninitialized() };
let mut curr = buf.len() as isize; let mut curr = buf.len() as isize;
let buf_ptr = buf.as_mut_ptr(); let buf_ptr = buf.as_mut_ptr();
let lut_ptr = DEC_DIGITS_LUT.as_ptr(); let lut_ptr = DEC_DIGITS_LUT.as_ptr();

View file

@ -59,6 +59,8 @@ fn main() {
assert_eq!("20000000000000000000000", format!("{:o}", j)); assert_eq!("20000000000000000000000", format!("{:o}", j));
assert_eq!("10000000000000000000000000000000000000000000000000000000000000000000", assert_eq!("10000000000000000000000000000000000000000000000000000000000000000000",
format!("{:b}", j)); format!("{:b}", j));
assert_eq!("340282366920938463463374607431768211455",
format!("{}", u128::max_value()));
assert_eq!("147573952589676412928", format!("{:?}", j)); assert_eq!("147573952589676412928", format!("{:?}", j));
// common traits // common traits
x.clone(); x.clone();