ramp icon indicating copy to clipboard operation
ramp copied to clipboard

Size calculation in pub fn to_str_radix

Open Phaiax opened this issue 9 years ago • 1 comments
trafficstars

Here, num_base_digits is called with size()-1:

https://github.com/Aatch/ramp/blob/master/src/int.rs#L275

So if the Int has one limb, num_base_digits is called with n=0, that will cause return 1 independent of base.

https://github.com/Aatch/ramp/blob/master/src/ll/base.rs#L48


I just found another related problem, but that would better be part of another issue.

Phaiax avatar Mar 12 '16 09:03 Phaiax

Ah, good catch. Fortunately it's only used for pre-allocating the Vec, so it doesn't cause any real issues. Not sure why it passes size - 1 there.

Aatch avatar Aug 04 '16 03:08 Aatch