Aatch / ramp

RAMP - Rust Arithmetic in Multiple Precision
Apache License 2.0
261 stars 38 forks source link

Size calculation in pub fn to_str_radix #63

Open Phaiax opened 8 years ago

Phaiax commented 8 years ago

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.

Aatch commented 8 years ago

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.