[][src]Function finance_solution::convert_epr_to_apr

pub fn convert_epr_to_apr(epr: f64, compounding_periods_in_year: u32) -> f64

Convert periodic rate to APR (aka Annual rate, nominal interest rate, Annual Percentage Rate). Returns f64.

Related Functions:

The formula is:

Arguments

  • epr - The input rate (periodic rate), expressed as a floating point number. For instance 0.05 indicates 5%. Often appears as r or i in formulas.
  • periods - The number of compounding periods in a year. Often appears as n or t.

Panics

  • periods - must be a u32 value greater than or equal to 1.

Example

Convert a periodic rate to the annual rate (APR).

use finance_solution::*;
// The periodic rate is 3.4%. There are 12 compounding periods per year.
let (periodic_rate, periods) = (0.034, 12);

let apr = convert_rate::convert_epr_to_apr(periodic_rate, periods);
 
// Confirm that the APR is correct.
assert_approx_equal!(0.4080, apr);