Skip to content

Commit b63be9c

Browse files
committed
Say "Decimal" rather than "Decimal128"
1 parent bc9f3c5 commit b63be9c

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

README.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -37,21 +37,21 @@ Many currencies tend to be expressed with decimal quantities. Although it’s po
3737

3838
#### Sample code
3939

40-
In the examples that follow, we'll use `Decimal128` objects. (Why "Decimal128"? See below!)
40+
In the examples that follow, we'll use `Decimal` objects.
4141

4242
##### Add up the items of a bill, then add sales tax
4343

4444
```js
4545
function calculateBill(items, tax) {
46-
let total = new Decimal128(0);
46+
let total = new Decimal(0);
4747
for (let {price, count} of items) {
48-
total = total.add(new Decimal128(price).times(new Decimal128(count)));
48+
total = total.add(new Decimal(price).times(new Decimal(count)));
4949
}
50-
return total.multiply(tax.add(new Decimal128(1)));
50+
return total.multiply(tax.add(new Decimal(1)));
5151
}
5252

5353
let items = [{price: "1.25", count: 5}, {price: "5.00", count: 1}];
54-
let tax = new Decimal128("0.0735");
54+
let tax = new Decimal("0.0735");
5555
let total = calculateBill(items, tax);
5656
console.log(total.toFixed(2));
5757
```
@@ -61,9 +61,9 @@ console.log(total.toFixed(2));
6161
Let's convert USD to EUR, given the exchange rate EUR --> USD.
6262

6363
```js
64-
let exchangeRateEurToUsd = new Decimal128("1.09");
65-
let amountInUsd = new Decimal128("450.27");
66-
let exchangeRateUsdToEur = new Decimal128(1).divide(exchangeRateEurToUsd);
64+
let exchangeRateEurToUsd = new Decimal("1.09");
65+
let amountInUsd = new Decimal("450.27");
66+
let exchangeRateUsdToEur = new Decimal(1).divide(exchangeRateEurToUsd);
6767

6868
let amountInEur = exchangeRateUsdToEur.multiply(amountInUsd);
6969
console.log(amountInEur.round(2).toString());
@@ -77,9 +77,9 @@ const options = {
7777
maximumFractionDigits: 4
7878
};
7979
const formatter = new Intl.NumberFormat(options)
80-
formatter.format(new Decimal128("1.0")); // "1.00"
81-
formatter.format(new Decimal128("1.000")); // "1.000"
82-
formatter.format(new Decimal128("1.00000")); // "1.000"
80+
formatter.format(new Decimal("1.0")); // "1.00"
81+
formatter.format(new Decimal("1.000")); // "1.000"
82+
formatter.format(new Decimal("1.00000")); // "1.000"
8383
```
8484

8585
#### Why use JavaScript for this case?
@@ -149,7 +149,7 @@ const client = new Client({
149149
// ...more options
150150
});
151151

152-
const boost = new Decimal128("1.05");
152+
const boost = new Decimal("1.05");
153153

154154
client.query('SELECT prices FROM data_with_numbers', (err, res) => {
155155
if (err) throw err;
@@ -254,11 +254,11 @@ The library of numerical functions here is kept deliberately minimal. It is base
254254

255255
### Conversion to and from other data types
256256

257-
Decimal128 objects can be constructed from Numbers, Strings, and BigInts. Similarly, there will be conversion from Decimal128 objects to Numbers, String, and BigInts.
257+
Decimal objects can be constructed from Numbers, Strings, and BigInts. Similarly, there will be conversion from Decimal objects to Numbers, String, and BigInts.
258258

259259
### String formatting
260260

261-
+ `toString()` is similar to the behavior on Number, e.g., `new Decimal128("123.456").toString()` is `"123.456"`. ([#12](https://github.com/tc39/proposal-decimal/issues/12))
261+
+ `toString()` is similar to the behavior on Number, e.g., `new Decimal("123.456").toString()` is `"123.456"`. ([#12](https://github.com/tc39/proposal-decimal/issues/12))
262262
+ `toFixed()` is similar to Number's `toFixed()`
263263
+ `toPrecison()` is similar to Number's `toPrecision()`
264264
+ `toExponential()` is similar to Number's `toExponential()`

0 commit comments

Comments
 (0)