#roman #numerical #system #converion

numerus

Convert integers to roman numerals and vice versa

2 releases

0.1.1 Sep 3, 2019
0.1.0 Sep 1, 2019

#252 in Value formatting

26 downloads per month

MIT license

10KB
129 lines

numerus

Build Status crates.io

Convert integers to roman numerals and vice versa

Examples

Convert from int to roman numeral.

    use numerus::int_to_roman_upper;
    let a = 14;
    assert_eq!(int_to_roman_upper(a).unwrap(), "XIV");

Convert a roman numeral to int

    use numerus::roman_to_int;
    let year = "MCMXCVIII";
    assert_eq!(roman_to_int(year).unwrap(), 1998);

For more examples see the documentaion


lib.rs:

Numerus

Convert integers to roman numerals and vice versa

Examples

Convert from integer to an uppercase roman numeral.

    use numerus::int_to_roman_upper;

    let a = 14;
    assert_eq!(int_to_roman_upper(a).unwrap(), "XIV");

Convert from integer to a lowercase roman numeral.

    use numerus::int_to_roman_lower;

    let a = 789;
    assert_eq!(int_to_roman_lower(a).unwrap(), "dcclxxxix");

Convert from a roman numeral to an integer

    use numerus::roman_to_int;

    let year = "MCMXCVIII";
    assert_eq!(roman_to_int(year).unwrap(), 1998);

See functions documentation for more information about error handling

No runtime deps