diff --git a/backend/README.md b/backend/README.md index 62efff3..ee53789 100644 --- a/backend/README.md +++ b/backend/README.md @@ -56,6 +56,13 @@ src - [Decimal.js](https://mikemcl.github.io/decimal.js/) is used for the basic arithmetic operations. 4. Evaluate the result by `Fraction.evaluate()`. +### Example +1. Input string: `5 / 3 / 4 * 9 - 2 * 3 / 8` +2. Parse into sub-expressions: `5 / 3 / 4 * 9` and `-2 * 3 / 8` +3. Turn these into fractions: $\frac{5 * 9}{3 * 4}$ and - $\frac{2 * 3}{8}$ +4. find equivalent fractions with same denominator: $\frac{90}{24}$ and - $\frac{18}{24}$ +5. Sum these fractions: $\frac{90}{24} - \frac{18}{24} = \frac{72}{24} = 3$ + ### Limitations - All whitespace is ignored, therefore `1 + 2 3` will consider as `1 + 23` - `negative sign` is only allowed at the beginning of an expression but not after multiplication or division