staquia 0.2.0

Lexicographic positions: short strings that keep the order of a list, so moving an item writes one row.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
//! Moves the digits that reached the base to the next index.

use crate::number::Digits;

/// Moves to the next index every digit equal to or bigger than the base.
pub(crate) fn resolve_overflow(base: i32, number: &mut Digits) {
    let mut n = number.lower;
    while n <= number.upper {
        if number.get(n) >= base {
            number.update(n, -base);
            number.update(n + 1, 1);
        }
        n += 1;
    }
}