Skip to content

Commit

Permalink
rational-numbers: Clarify that denominator can be 0 (exercism#1856)
Browse files Browse the repository at this point in the history
* rational-numbers: Clarify that denominator can be 0

In some languages the denominator can be 0 and therefore the track's implementation of this exercise may expect it. Stating `b != 0` in the description may be misleading if the track expects it.

* Move info to note
  • Loading branch information
SaschaMann authored Oct 26, 2021
1 parent 124c2ad commit 3d713dc
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions exercises/rational-numbers/description.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 3d713dc

Please sign in to comment.