[][src]Function finance_solution::convert_apr_to_ear_solution

pub fn convert_apr_to_ear_solution(
    apr: f64,
    compounding_periods_in_year: u32
) -> ConvertRateSolution

Convert an APR to EAR (effective annual rate). Returns a custom type with additional functionality and extra information available in the dbg!().

Related Functions:

  • apr macro to convert APR to all forms of rate conversion, and return a custom type with additional functionality and extra information available in the dbg!().
  • convert_apr_to_ear to convert APR to EAR and return the f64 value instead of a solution struct.

The formula:

Arguments

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

Panics

  • periods - must be a u32 value greater than 0.

Example

/// Convert annual rate to effective annual rate.

use finance_solution::*;
// The annual percentage rate is 3.4%.
let nominal_rate = 0.034;

// There are 12 compounding periods per year (monthly compounding).
let periods = 12;

let effective_annual_rate = convert_apr_to_ear_solution(nominal_rate, periods).ear();
 
// Confirm that the EAR is correct.
assert_approx_equal!(0.034535, effective_annual_rate);