base79 0.1.0

Textual representation of and utility functions for base-79 fractional numbers with arbitrary precision
Documentation
  • Coverage
  • 20%
    2 out of 10 items documented1 out of 8 items with examples
  • Size
  • Source code size: 15.28 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.83 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 9s Average build duration of successful builds.
  • all releases: 9s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • dchenk/base79
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • dchenk

base79

This library provides a textual representation of base-79 fractional numbers with arbitrary precision, without a leading zero or decimal point. Given any two base-79 numbers, this library can also give you the midpoint. This can be useful in real-time collaborative applications and in applications where users can manually order records arbitrarily.

This is a fork of github.com/seungha-kim/base79 but simplified to 79 digits to not deal with some of the awkward characters at the ends of the printable ASCII range.

Documentation

Example

use base79::Base79;
use std::str::FromStr;

fn main() {
    use base79::Base79;
    use std::str::FromStr;

    let n1 = Base79::mid();
    assert_eq!(n1.to_string(), "R");
    assert_eq!(n1.raw_digits(), vec![39]);

    let n2 = Base79::avg_with_zero(&n1);
    assert_eq!(n2.to_string(), ">");
    assert_eq!(n2.raw_digits(), vec![19]);

    let n3 = Base79::avg_with_one(&n1);
    assert_eq!(n3.to_string(), "f");

    let n4 = Base79::avg(&n1, &n2);
    assert_eq!(n4.to_string(), "H");

    let n5 = Base79::from_str("s?Q^Z").unwrap();
    assert_eq!(n5.raw_digits(), vec![72, 20, 38, 51, 47]);
}