Function transmission_sys::tr_truncd
source · Expand description
@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 | +————————+