Skip to content

Commit 3d713dc

Browse files
authored
rational-numbers: Clarify that denominator can be 0 (#1856)
* 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
1 parent 124c2ad commit 3d713dc

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

exercises/rational-numbers/description.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

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

5+
~~~~exercism/note
6+
Note that mathematically, the denominator can't be zero.
7+
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.
8+
In those cases, the denominator and numerator generally still can't both be zero at once.
9+
~~~~
10+
511
The absolute value `|r|` of the rational number `r = a/b` is equal to `|a|/|b|`.
612

713
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₂)`.

0 commit comments

Comments
 (0)