tcal_rs 0.1.0

Number theory functions library - Rust port of libqalculate number theory module
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
// Standalone fprice module that doesn't depend on rug

/// Formats a number with comma separators (e.g., 1,234,567)
pub fn fprice(value: i64) -> String {
    let s = value.to_string();
    let chars: Vec<char> = s.chars().collect();
    let mut result = String::new();

    for (i, c) in chars.iter().enumerate() {
        if i > 0 && (chars.len() - i) % 3 == 0 {
            result.push(',');
        }
        result.push(*c);
    }

    result
}