Skip to content

Commit

Permalink
rational-numbers: Clarify that denominator can be 0 (JuliaLang#459)
Browse files Browse the repository at this point in the history
  • Loading branch information
SaschaMann authored Oct 30, 2021
1 parent a5dd5c5 commit ac2e005
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions exercises/practice/rational-numbers/.docs/instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

A rational number is defined as the quotient of two integers `a` and `b`, called the numerator and denominator, respectively, where `b != 0`.

~~~~exercism/note
Note that mathematically, the denominator can't be zero.
However in many implementations of rational numbers, you will find that the denominator is allowed to be zero with behaviour similar to positive or negative infinity in floating point numbers.
In those cases, the denominator and numerator generally still can't both be zero at once.
~~~~

The absolute value `|r|` of the rational number `r = a/b` is equal to `|a|/|b|`.

The sum of two rational numbers `r₁ = a₁/b₁` and `r₂ = a₂/b₂` is `r₁ + r₂ = a₁/b₁ + a₂/b₂ = (a₁ * b₂ + a₂ * b₁) / (b₁ * b₂)`.
Expand Down

0 comments on commit ac2e005

Please sign in to comment.