Skip to content

Commit de96d0c

Browse files
committed
Address reviewer feedback
- Fix invalid toPrecision(20) chaining syntax in why-decimal.md - Add missing parentheses to isNaN() and isFinite() method calls in cookbook.md - Fix grammar: "the number" → "the numbers" in why-decimal.md - Update exchange rate examples to use realistic rates (0.85 → 0.92545)
1 parent fc3d02e commit de96d0c

File tree

4 files changed

+13
-20
lines changed

4 files changed

+13
-20
lines changed

docs/cookbook.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -239,9 +239,9 @@ function convertCurrency(amount, rate, decimals = 2) {
239239
Example conversions:
240240

241241
```javascript
242-
// Convert 100 USD to EUR at rate 0.85
243-
const eurAmount = convertCurrency("100.00", "0.85");
244-
console.log(eurAmount); // => "85.00"
242+
// Convert 100 USD to EUR at rate 0.92545
243+
const eurAmount = convertCurrency("100.00", "0.92545");
244+
console.log(eurAmount); // => "92.55"
245245

246246
// Convert with more precision for crypto
247247
const btcAmount = convertCurrency("1000.00", "0.000024", 8);
@@ -482,10 +482,10 @@ function parseUserDecimal(input) {
482482
const decimal = new Decimal(input);
483483

484484
// Check for special values
485-
if (decimal.isNaN) {
485+
if (decimal.isNaN()) {
486486
return { success: false, error: "Invalid number" };
487487
}
488-
if (!decimal.isFinite) {
488+
if (!decimal.isFinite()) {
489489
return { success: false, error: "Number must be finite" };
490490
}
491491

@@ -511,7 +511,7 @@ function safeDivide(dividend, divisor) {
511511

512512
const result = a.divide(b);
513513

514-
if (!result.isFinite) {
514+
if (!result.isFinite()) {
515515
return { success: false, error: "Result is infinite" };
516516
}
517517

docs/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,9 @@ console.log(total.toFixed(2)); // => "108.24"
9393

9494
```js
9595
const amountUSD = new Decimal("100.00");
96-
const exchangeRate = new Decimal("0.85"); // USD to EUR
96+
const exchangeRate = new Decimal("0.92545"); // USD to EUR
9797
const amountEUR = amountUSD.multiply(exchangeRate);
98-
console.log(amountEUR.toFixed(2)); // => "85.00"
98+
console.log(amountEUR.toFixed(2)); // => "92.55"
9999
```
100100

101101
## Other Documentation

docs/why-decimal.md

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,9 @@ binary floating-point:
2727

2828
```javascript
2929
// None of these are exact in binary
30-
(0.1)
31-
.toPrecision(20)(
32-
// => "0.10000000000000000555"
33-
0.2,
34-
)
35-
.toPrecision(20)(
36-
// => "0.20000000000000001110"
37-
0.3,
38-
)
39-
.toPrecision(20); // => "0.29999999999999998890"
30+
(0.1).toPrecision(20); // => "0.10000000000000000555"
31+
(0.2).toPrecision(20); // => "0.20000000000000001110"
32+
(0.3).toPrecision(20); // => "0.29999999999999998890"
4033
```
4134

4235
### Real-World Impact
@@ -204,7 +197,7 @@ decimals.forEach((d) => {
204197
// 0.9: NOT exact
205198
```
206199

207-
Out of the single-digit decimals, only 0.5 can be exactly represented! This is because 0.5 = 1/2, and powers of 2 are the only fractions that binary can represent exactly. Looking at, say, the number 0.00, 0.01, …, 1.00, the results are even more startling.
200+
Out of the single-digit decimals, only 0.5 can be exactly represented! This is because 0.5 = 1/2, and powers of 2 are the only fractions that binary can represent exactly. Looking at, say, the numbers 0.00, 0.01, …, 1.00, the results are even more startling.
208201

209202
## What Decimal Doesn't Solve
210203

index.html

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)