num2ordinal 0.1.1

A simple Rust crate for converting integers to ordinal representations, including support for alphabetic and Roman numeral formats.
Documentation
  • Coverage
  • 57.14%
    4 out of 7 items documented0 out of 7 items with examples
  • Size
  • Source code size: 10.9 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 293.56 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 7s Average build duration of successful builds.
  • all releases: 8s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • levish0/num2ordinal
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • levish0

num2ordinal

A simple Rust crate for converting integers to ordinal representations, including support for alphabetic and Roman numeral formats.

Features

  • Alphabetic Representation: Converts numbers to a base-26 alphabetic representation (e.g., 1 -> A, 27 -> AA).
  • Roman Numerals: Converts numbers to their standard Roman numeral representation (up to 1000 using standard Roman numerals).
  • Extended Roman Numerals: Converts numbers to extended Roman numerals, supporting values up to 10000 (using extended Roman numerals).

Installation

Add this to your Cargo.toml:

[dependencies]

num2ordinal = "0.1"

Usage

Alphabetic Representation

The to_alphabet function converts an integer to its corresponding alphabetic representation, following the Excel-style column naming convention.

use num2ordinal::alphabet::to_alphabet;

fn main() {
    let num = 1999;
    let alphabet = to_alphabet(num);
    println!("Alphabetic representation for {} is {}", num, alphabet);
    // Alphabetic representation for 1999 is BXW
}

Roman Numerals

use num2ordinal::roman::to_roman;

fn main() {
    let num = 1999;
    let roman = to_roman(num);
    println!("Roman numeral for {} is {}", num, roman);
    // Roman numeral for 1999 is MCMXCIX
}

Extended Roman Numerals

use num2ordinal::roman::to_roman;

fn main() {
    let num = 14000;
    let extended_roman = to_extended_roman(num);
    println!("Extended Roman numeral for {} is {}", num, extended_roman);
    // Extended Roman numeral for 14000 is X̄ĪV̄
}

License

This crate is licensed under the MIT license. See LICENSE for more details.