Functional Weave
Code in Rust

education.gpa@1.0.0

README.md

1,968 bytes · view raw

# education.gpa

A grade point average on the 4.0 scale: each course's grade points times its
credit hours, summed (the quality points), divided by the credits that count,
and rounded once to hundredths. The answer is an integer in hundredths
(`312` is a 3.12 GPA), so no float carries it.

## The grade-point table

Institutions set their own tables, so pass yours as `gradePoints`. With
`null` the default is the common US conversion published by the College
Board (BigFuture, "How to Convert Your GPA to a 4.0 Scale"): A+ and A 4.0,
A- 3.7, B+ 3.3, B 3.0, B- 2.7, C+ 2.3, C 2.0, C- 1.7, D+ 1.3, D 1.0, E and F
0.0. The default also knows P (pass) and W (withdrawn) as grades that do not
count. It has no D-: schools that use one disagree on its value (0.7 is
common), so a D- is refused unless your table has it. Some schools give A+
4.33; pass a table with `points` 433 for that.

The table is a convention, not a rule that changes by date, so it carries no
`effective` columns and always ships whole.

## Decisions

- **Credit-weighted.** A 4-credit B+ counts four times a 1-credit A. The
  unweighted mean of the grade points is a common mistake; a vector pins it.
- **Fails count, passes do not.** An F adds its credits with 0 points; a
  grade whose `points` is null (P, W, I, audit) is left out of both sums and
  its credits reported as `excludedCredits`.
- **One rounding, the caller's mode.** Many registrars truncate (`down`)
  rather than round; the exact quality points are returned too.
- **No course that counts means no GPA**: `gpa` is null, not 0.00.
- Grades match exactly, case included: "a" is not "A".
- Repeated-course replacement, weighted honours/AP scales and transfer
  credit rules are institution policy and out of scope: pass only the
  courses that count.

## Sources

- College Board, BigFuture, "How to Convert Your GPA to a 4.0 Scale":
  https://bigfuture.collegeboard.org/plan-for-college/get-started/how-to-calculate-gpa-4.0-scale