Skip to main content

from_roman

Function from_roman 

Source
pub fn from_roman(text: &str, strict_modern: bool) -> Result<i64>
Expand description

A Roman numeral, upper or lower case, read as a number: music21’s fromRoman. The medieval IIII and IC are read too, unless strict_modern refuses a subtraction of less than a tenth.

use music21::common::numbertools::from_roman;

assert_eq!(from_roman("MCDLXXXIX", false)?, 1489);
assert_eq!(from_roman("ic", false)?, 99);
assert!(from_roman("ic", true).is_err());

§Errors

A letter that is not a numeral, or a subtraction no Roman wrote.