Module 1 · Mathematical Language and Quantitative Reasoning Lesson 4 of 120
Percentage Change, Percentage Points, and Basis Points
A loan-rate change reported three different ways.
Transcript
22 sentences · select one to jump thereCheck your understanding
What is a change from 3% to 3.5% in basis points?
Code lab
Run it yourself
The lesson source in 7 languages. Edit it, run TypeScript and Python right here, and compare with the expected output.
/**
* Fintech Math Bootcamp · Lesson 004 of 120
* Percentage Change, Percentage Points, and Basis Points
* Module 01: Mathematical Language and Quantitative Reasoning
*
* Scenario: A loan-rate change reported three different ways
* Rule: 8% → 9% = +1 pp = +100 bp = +12.5% relative
*
* Try it: What is a change from 3% to 3.5% in basis points?
*
* Lesson article: https://thefintechbuilder.com/financial-mathematics-statistics-and-data-foundations/mathematical-language-and-quantitative-reasoning/percentage-change-percentage-points-and-basis-points/
* Free course: https://courses.thefintechbuilder.com
* Synthetic teaching example, not financial advice or a production library.
*/
export function lesson004() {
const before = 0.08, after = 0.09;
const delta = after - before;
const result = {
points: delta * 100,
basisPoints: delta * 10000,
relative: delta / before
};
return result;
}
export const checkedResult = {"points":0.9999999999999996,"basisPoints":99.99999999999994,"relative":0.12499999999999993};
// Run this file directly: npx tsx lessons/01-mathematical-language-and-quantitative-reasoning/004-percentage-change-percentage-points-and-basis-points.ts
if (process.argv[1] && import.meta.url.endsWith(process.argv[1].replace(/\\/g, "/").split("/").pop()!)) {
console.log(JSON.stringify(lesson004(), null, 2));
}
Your output
Press Run to execute the code in your browser.
Expected output
{
"points": 0.9999999999999996,
"basisPoints": 99.99999999999994,
"relative": 0.12499999999999993
}"""
Fintech Math Bootcamp · Lesson 004 of 120
Percentage Change, Percentage Points, and Basis Points
Module 01: Mathematical Language and Quantitative Reasoning
Scenario: A loan-rate change reported three different ways
Rule: 8% → 9% = +1 pp = +100 bp = +12.5% relative
Try it: What is a change from 3% to 3.5% in basis points?
Lesson article: https://thefintechbuilder.com/financial-mathematics-statistics-and-data-foundations/mathematical-language-and-quantitative-reasoning/percentage-change-percentage-points-and-basis-points/
Free course: https://courses.thefintechbuilder.com
Synthetic teaching example, not financial advice or a production library.
Run it: python main.py
"""
import json
def lesson004() -> dict:
before, after = 0.08, 0.09
delta = after - before
result = {
"points": delta * 100,
"basisPoints": delta * 10000,
"relative": delta / before,
}
return result
if __name__ == "__main__":
print(json.dumps(lesson004(), indent=2))
Your output
Press Run to execute the code in your browser.
Expected output
{
"points": 0.9999999999999996,
"basisPoints": 99.99999999999994,
"relative": 0.12499999999999993
}/**
* Fintech Math Bootcamp · Lesson 004 of 120
* Percentage Change, Percentage Points, and Basis Points
* Module 01: Mathematical Language and Quantitative Reasoning
*
* Scenario: A loan-rate change reported three different ways
* Rule: 8% → 9% = +1 pp = +100 bp = +12.5% relative
*
* Try it: What is a change from 3% to 3.5% in basis points?
*
* Lesson article: https://thefintechbuilder.com/financial-mathematics-statistics-and-data-foundations/mathematical-language-and-quantitative-reasoning/percentage-change-percentage-points-and-basis-points/
* Free course: https://courses.thefintechbuilder.com
* Synthetic teaching example, not financial advice or a production library.
*
* Run it: javac Main.java && java Main
*/
public class Main {
static final class RateChange {
final double points;
final double basisPoints;
final double relative;
RateChange(double points, double basisPoints, double relative) {
this.points = points;
this.basisPoints = basisPoints;
this.relative = relative;
}
}
static RateChange lesson004() {
double before = 0.08, after = 0.09;
double delta = after - before;
RateChange result = new RateChange(
delta * 100,
delta * 10000,
delta / before
);
return result;
}
public static void main(String[] args) {
RateChange result = lesson004();
System.out.println(object(
"points", num(result.points),
"basisPoints", num(result.basisPoints),
"relative", num(result.relative)));
}
// Formats a double the way JSON.stringify does: whole numbers without ".0", null for NaN or infinity.
static String num(double x) {
if (Double.isNaN(x) || Double.isInfinite(x)) return "null";
if (x == Math.rint(x) && Math.abs(x) < 1e15) return String.valueOf((long) x);
return String.valueOf(x);
}
static String quote(String text) {
return "\"" + text.replace("\\", "\\\\").replace("\"", "\\\"") + "\"";
}
// Indents an already formatted JSON value by one level.
static String nested(String json) {
return json.replace("\n", "\n ");
}
static String object(String... keysAndValues) {
if (keysAndValues.length == 0) return "{}";
StringBuilder out = new StringBuilder("{");
for (int i = 0; i < keysAndValues.length; i += 2) {
out.append(i == 0 ? "\n " : ",\n ")
.append(quote(keysAndValues[i])).append(": ").append(nested(keysAndValues[i + 1]));
}
return out.append("\n}").toString();
}
}
No browser runner for Java yet
Read the code here, then run it in your own toolchain or a ready-made cloud workspace.
Expected output
{
"points": 0.9999999999999996,
"basisPoints": 99.99999999999994,
"relative": 0.12499999999999993
}// Fintech Math Bootcamp · Lesson 004 of 120
// Percentage Change, Percentage Points, and Basis Points
// Module 01: Mathematical Language and Quantitative Reasoning
//
// Scenario: A loan-rate change reported three different ways
// Rule: 8% → 9% = +1 pp = +100 bp = +12.5% relative
//
// Try it: What is a change from 3% to 3.5% in basis points?
//
// Lesson article: https://thefintechbuilder.com/financial-mathematics-statistics-and-data-foundations/mathematical-language-and-quantitative-reasoning/percentage-change-percentage-points-and-basis-points/
// Free course: https://courses.thefintechbuilder.com
// Synthetic teaching example, not financial advice or a production library.
//
// Run it: go run main.go
package main
import (
"encoding/json"
"fmt"
)
type RateChange struct {
Points float64 `json:"points"`
BasisPoints float64 `json:"basisPoints"`
Relative float64 `json:"relative"`
}
func lesson004() RateChange {
before, after := 0.08, 0.09
delta := after - before
result := RateChange{
Points: delta * 100,
BasisPoints: delta * 10000,
Relative: delta / before,
}
return result
}
func main() {
printJSON(lesson004())
}
// printJSON prints a value as JSON indented with two spaces, like JSON.stringify(value, null, 2).
func printJSON(value any) {
out, err := json.MarshalIndent(value, "", " ")
if err != nil {
panic(err)
}
fmt.Println(string(out))
}
No browser runner for Go yet
Read the code here, then run it in your own toolchain or a ready-made cloud workspace.
Expected output
{
"points": 0.9999999999999996,
"basisPoints": 99.99999999999994,
"relative": 0.12499999999999993
}/**
* Fintech Math Bootcamp · Lesson 004 of 120
* Percentage Change, Percentage Points, and Basis Points
* Module 01: Mathematical Language and Quantitative Reasoning
*
* Scenario: A loan-rate change reported three different ways
* Rule: 8% → 9% = +1 pp = +100 bp = +12.5% relative
*
* Try it: What is a change from 3% to 3.5% in basis points?
*
* Lesson article: https://thefintechbuilder.com/financial-mathematics-statistics-and-data-foundations/mathematical-language-and-quantitative-reasoning/percentage-change-percentage-points-and-basis-points/
* Free course: https://courses.thefintechbuilder.com
* Synthetic teaching example, not financial advice or a production library.
*
* Run it: g++ -std=c++17 -o main main.cpp && ./main
*/
#include <charconv>
#include <cmath>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
// Formats a double the way JSON.stringify does: shortest round-trip form, null for NaN or infinity.
std::string num(double x) {
if (!std::isfinite(x)) return "null";
char buffer[32];
auto [end, error] = std::to_chars(buffer, buffer + sizeof buffer, x);
(void)error;
return std::string(buffer, end);
}
std::string quote(const std::string& text) {
std::string out = "\"";
for (char c : text) {
if (c == '"' || c == '\\') out += '\\';
out += c;
}
return out + "\"";
}
// Indents an already formatted JSON value by one level.
std::string nested(const std::string& json) {
std::string out;
for (char c : json) {
out += c;
if (c == '\n') out += " ";
}
return out;
}
std::string object(const std::vector<std::pair<std::string, std::string>>& fields) {
if (fields.empty()) return "{}";
std::string out = "{";
for (std::size_t i = 0; i < fields.size(); ++i) {
out += i == 0 ? "\n " : ",\n ";
out += quote(fields[i].first) + ": " + nested(fields[i].second);
}
return out + "\n}";
}
struct RateChange {
double points;
double basisPoints;
double relative;
};
RateChange lesson004() {
const double before = 0.08, after = 0.09;
const double delta = after - before;
const RateChange result{
delta * 100,
delta * 10000,
delta / before
};
return result;
}
int main() {
const RateChange result = lesson004();
std::cout << object({
{"points", num(result.points)},
{"basisPoints", num(result.basisPoints)},
{"relative", num(result.relative)}
}) << "\n";
}
No browser runner for C++ yet
Read the code here, then run it in your own toolchain or a ready-made cloud workspace.
Expected output
{
"points": 0.9999999999999996,
"basisPoints": 99.99999999999994,
"relative": 0.12499999999999993
}//! Fintech Math Bootcamp · Lesson 004 of 120
//! Percentage Change, Percentage Points, and Basis Points
//! Module 01: Mathematical Language and Quantitative Reasoning
//!
//! Scenario: A loan-rate change reported three different ways
//! Rule: 8% → 9% = +1 pp = +100 bp = +12.5% relative
//!
//! Try it: What is a change from 3% to 3.5% in basis points?
//!
//! Lesson article: https://thefintechbuilder.com/financial-mathematics-statistics-and-data-foundations/mathematical-language-and-quantitative-reasoning/percentage-change-percentage-points-and-basis-points/
//! Free course: https://courses.thefintechbuilder.com
//! Synthetic teaching example, not financial advice or a production library.
//!
//! Run it: rustc main.rs && ./main
struct RateChange {
points: f64,
basis_points: f64,
relative: f64,
}
fn lesson004() -> RateChange {
let (before, after) = (0.08, 0.09);
let delta = after - before;
let result = RateChange {
points: delta * 100.0,
basis_points: delta * 10000.0,
relative: delta / before,
};
result
}
fn main() {
let result = lesson004();
println!(
"{}",
object(&[
("points", num(result.points)),
("basisPoints", num(result.basis_points)),
("relative", num(result.relative)),
])
);
}
/// Formats a number the way JSON.stringify does: shortest round-trip form, null for NaN or infinity.
fn num(x: f64) -> String {
if x.is_finite() {
format!("{}", x)
} else {
"null".to_string()
}
}
fn quote(text: &str) -> String {
format!("\"{}\"", text.replace('\\', "\\\\").replace('"', "\\\""))
}
/// Indents an already formatted JSON value by one level.
fn nested(json: &str) -> String {
json.replace('\n', "\n ")
}
fn object(fields: &[(&str, String)]) -> String {
if fields.is_empty() {
return "{}".to_string();
}
let lines: Vec<String> = fields
.iter()
.map(|(key, value)| format!(" {}: {}", quote(key), nested(value)))
.collect();
format!("{{\n{}\n}}", lines.join(",\n"))
}
No browser runner for Rust yet
Read the code here, then run it in your own toolchain or a ready-made cloud workspace.
Expected output
{
"points": 0.9999999999999996,
"basisPoints": 99.99999999999994,
"relative": 0.12499999999999993
}/**
* Fintech Math Bootcamp · Lesson 004 of 120
* Percentage Change, Percentage Points, and Basis Points
* Module 01: Mathematical Language and Quantitative Reasoning
*
* Scenario: A loan-rate change reported three different ways
* Rule: 8% → 9% = +1 pp = +100 bp = +12.5% relative
*
* Try it: What is a change from 3% to 3.5% in basis points?
*
* Lesson article: https://thefintechbuilder.com/financial-mathematics-statistics-and-data-foundations/mathematical-language-and-quantitative-reasoning/percentage-change-percentage-points-and-basis-points/
* Free course: https://courses.thefintechbuilder.com
* Synthetic teaching example, not financial advice or a production library.
*
* Run it: dotnet run (inside a console project that holds this Program.cs)
*/
using System.Text.Json;
var jsonOptions = new JsonSerializerOptions { WriteIndented = true, PropertyNamingPolicy = JsonNamingPolicy.CamelCase };
Console.WriteLine(JsonSerializer.Serialize(Lesson004(), jsonOptions));
static RateChange Lesson004()
{
double before = 0.08, after = 0.09;
var delta = after - before;
var result = new RateChange(
Points: delta * 100,
BasisPoints: delta * 10000,
Relative: delta / before
);
return result;
}
record RateChange(double Points, double BasisPoints, double Relative);
No browser runner for C# yet
Read the code here, then run it in your own toolchain or a ready-made cloud workspace.
Expected output
{
"points": 0.9999999999999996,
"basisPoints": 99.99999999999994,
"relative": 0.12499999999999993
}Prefer your own machine? Every file is in the course repository · open it in Codespaces.
Lesson notes
The rule
8% → 9% = +1 pp = +100 bp = +12.5% relative