Browse Source

1448 fix(sales): remove inconsistency in expected output

also clarify why small discrepancies can appear in results
pull/1464/head
Michele Sessa 2 years ago committed by Michele
parent
commit
88d3857a61
  1. 8
      subjects/sales/README.md

8
subjects/sales/README.md

@ -41,10 +41,12 @@ impl Cart {
### Example
```
[1.23, 3.12, 23.1]` => `[1.17, 2.98, 22.07]
[1.23, 3.12, 23.1]` => `[1.17, 2.98, 22.06]
```
Because `1.17 + 2.98 + 22.07` == `0 + 3.12 + 23.1`
Because `1.17 + 2.98 + 22.06` == `0 + 3.12 + 23.1`
Floats are rounded with a precision of two decimals which can create small discrepancies as per the example above.
This is a percentage calculation, and it can be applied to a set of three items. If the client purchases 9 items, they will receive three for free, with the discount applied to all items.
@ -92,7 +94,7 @@ And its output:
$ cargo run
Store { products: [("product A", 1.23), ("product B", 23.1), ("product C", 3.12)] }
[1.17, 2.98, 22.06]
Cart { items: [("product A", 1.23), ("product B", 23.1), ("product C", 3.12)], receipt: [1.17, 2.98, 22.07] }
Cart { items: [("product A", 1.23), ("product B", 23.1), ("product C", 3.12)], receipt: [1.17, 2.98, 22.06] }
$
```

Loading…
Cancel
Save