Skip to main content

proportion_to_fraction

Function proportion_to_fraction 

Source
pub fn proportion_to_fraction(value: FloatType) -> Option<(BigInt, BigInt)>
Expand description

The fraction with a denominator of at most sixteen nearest a proportion: music21’s proportionToFraction. None for a value that is not finite.

use music21::meter::tools::proportion_to_fraction;
use num::BigInt;

let third = proportion_to_fraction(0.333).unwrap();
assert_eq!(third, (BigInt::from(1), BigInt::from(3)));