Skip to main content

float_repr

Function float_repr 

Source
pub fn float_repr(value: FloatType) -> String
Expand description

A float written as Python’s repr writes it: the shortest digits that read back as the same float, 1.0 for a whole number, and an exponent below a ten-thousandth or from 1e16 up.

use music21::common::numbertools::float_repr;

assert_eq!(float_repr(1.0), "1.0");
assert_eq!(float_repr(0.125), "0.125");
assert_eq!(float_repr(1e16), "1e+16");
assert_eq!(float_repr(0.00001), "1e-05");