pub fn convert_ear_to_apr_solution(
ear: f64,
compounding_periods_in_year: u32,
) -> ConvertRateSolutionExpand description
Convert an EAR to APR. Returns solution struct with additional information and functionality.
Related Functions:
eargeneral-purpose macro to convert EAR into all rate variations.convert_ear_to_aprto convert EAR to APR and return an f64 value.
The formula is:
Note: This formula involves converting the EAR to EPR first, and then converting the EPR to APR.
§Arguments
rate- The input rate, expressed as a floating point number. For instance 0.05 would mean 5%. Often appears asroriin formulas.periods- The number of compounding periods in a year. Often appears asnort.
§Panics
periods- must be a u32 value greater than 0.
§Example
Convert effective annual rate (EAR) to annual percentage rate (APR).
use finance_solution::*;
// The effective annual rate is 3.453486936028982%
let effective_annual_rate = 0.03453486936028982;
// There are 12 compounding periods per year.
let periods = 12;
let ear_to_apr_solution = convert_rate::convert_ear_to_apr_solution(effective_annual_rate, periods);
// Confirm that the APR is correct.
assert_approx_equal!(0.034, ear_to_apr_solution.apr());