dtolnay / itoa

Fast function for printing integer primitives to a decimal string
Apache License 2.0
308 stars 37 forks source link

Fix `I64_MAX_LEN`: Set it to `21` #35

Closed NobodyXu closed 2 years ago

NobodyXu commented 2 years ago

Signed-off-by: Jiahao XU Jiahao_XU@outlook.com

NobodyXu commented 2 years ago

@dtolnay No offense, but can you please explain why it is correct for i64 as I have no clue why its max size is the same as u64?

Evaluating len(str(-(2 ** 64 - 1))) gives me 21 in python3.

dtolnay commented 2 years ago

i64::MIN and u64::MAX are both 20 characters. i64::MAX is 19 characters.

NobodyXu commented 2 years ago

i64::MIN and u64::MAX are both 20 characters. i64::MAX is 19 characters.

Thanks, I must have made some mistake calculating the max len.