[][src]Function transmission_sys::tr_truncd

pub unsafe extern "C" fn tr_truncd(x: f64, decimal_places: c_int) -> f64

@brief truncate a double value at a given number of decimal places.

this can be used to prevent a printf() call from rounding up: call with the decimal_places argument equal to the number of decimal places in the printf()'s precision:

  • printf("%.2f%%", 99.999) ==> "100.00%"

  • printf("%.2f%%", tr_truncd(99.999, 2)) ==> "99.99%" ^ ^ | These should match | +------------------------+