uniphil/buckets — pull request #5 by jameh (2014-08-13 03:22:55+00:00)
Title: Fix sig-fig minimization step to truly minimize sig figs.

In the minFigs algorithm, we wish to find a number in
[n-k, n] which has minimal sig figs. Previous implementation
floor-rounded n to the next lowest power of base to k. There is
always such a number since exp(floor(log(k))) < k. However,
it is possible for there to be a number in [n-k, n] which
has less sig figs, in particular this number (if it exists)
is given by floor-rounding n to the next highest power of
base to k.

Example test case:

old code (wrong)

```
> minFigs(10, [1101, 10000])
[[1100, 2070], [2070, 3040], [3040, 4010], [4010, 4980], [4980, 5950],
[5950, 6920], [6920, 7890], [7890, 8860], [8860, 9830], [9830, 10800]]
```

new code (right)

```
> minFigs(10, [1101, 10000])
[[1000, 1900], [1900, 2800], [2800, 3700], [3700, 4600], [4600, 5500],
[5500, 6400], [6400, 7300], [7300, 8200], [8200, 9100], [9100,
10000]]
```