@@ -13,7 +13,7 @@ Throws an error if the argument is not a valid **Ratio**.
13
13
14
14
Throws messages for errors:
15
15
- ** Ratio ${ratio} must be a record with 2 fields.**
16
- - ** Parameter must be a Ratio record, but ${ratio} has ${q(name)**
16
+ - ** Parameter must be a Ratio record, but ${ratio} has ${q(name)} **
17
17
18
18
``` js
19
19
assertIsRatio (aRatio);
@@ -23,12 +23,12 @@ assertIsRatio(aRatio);
23
23
- ** numerator** : ** BigInt**
24
24
- ** numeratorBrand** : ** [ Brand] ( /reference/ertp-api/brand ) **
25
25
- ** denominator** : ** BigInt** - Optional, defaults to 100n.
26
- - ** denominatorBrand) ** : ** Brand** - Optional, defaults to the * numeratorBrand* value.
26
+ - ** denominatorBrand** : ** Brand** - Optional, defaults to the * numeratorBrand* value.
27
27
- Returns: ** [ Ratio] ( ./zoe-data-types#ratio ) **
28
28
29
29
Returns a ** Ratio** based on the arguments passed into the function.
30
30
31
- By default, the * denominator* is 100n (i.e., the ** Ratio** is a percent).
31
+ By default, the * denominator* is 100n (i.e., the ** Ratio** is a percent).
32
32
33
33
``` js
34
34
// Use default values to create a ratio of 50 / 100 Quatloos
@@ -42,7 +42,7 @@ const ratio = makeRatio(75n, quatloosBrand, 4n, moolasBrand);
42
42
- ** denominatorAmount** : ** Amount**
43
43
- Returns: ** [ Ratio] ( ./zoe-data-types#ratio ) **
44
44
45
- Returns a ** Ratio** , representing a fraction and consisting of an immutable pair
45
+ Returns a ** Ratio** , representing a fraction and consisting of an immutable pair
46
46
of two ** Amounts** . The * numeratorAmount* is the ** Ratio's** numerator and
47
47
the * denominatorAmount* is the ** Ratio's** denominator.
48
48
@@ -73,11 +73,11 @@ would go
73
73
2 . 141 / 5 = 28.2
74
74
3 . Floor(28.2) = 28
75
75
76
- Throws errors with messages:
77
- - ** Expected an amount: ${amount}) ** : First argument isn't an ** Amount** .
76
+ Throws errors with messages:
77
+ - ** Expected an amount: ${amount}** : First argument isn't an ** Amount** .
78
78
- ** amount's brand ${q(amount.brand)} must match ratio's denominator ${q(
79
- ratio.denominator.brand** : The amount and ratio's denominator must have the same brand.
80
-
79
+ ratio.denominator.brand* )} * : The amount and ratio's denominator must have the same brand.
80
+
81
81
``` js
82
82
const exchangeRatio = makeRatio (3n , swissFrancBrand, 5n , dollarBrand);
83
83
const dollars47 = AmountMath .make (dollarBrand, 47n );
@@ -106,11 +106,11 @@ would go
106
106
2 . 141 / 5 = 28.2
107
107
3 . Ceiling(28.2) = 29
108
108
109
- Throws errors with messages:
110
- - ** Expected an amount: ${amount})** : First argument isn't an ** Amount** .
109
+ Throws errors with messages:
110
+ - ** Expected an amount: ${amount})** : First argument isn't an ** Amount** .
111
111
- ** amount's brand ${q(amount.brand)} must match ratio's denominator ${q(
112
- ratio.denominator.brand** : The amount and ratio's denominator must have the same brand.
113
-
112
+ ratio.denominator.brand** : The amount and ratio's denominator must have the same brand.
113
+
114
114
``` js
115
115
const exchangeRatio = makeRatio (3n , swissFrancBrand, 5n , dollarBrand);
116
116
const dollars47 = AmountMath .make (dollarBrand, 47n );
@@ -138,11 +138,11 @@ would go
138
138
2 . 141 / 5 = 28.2
139
139
3 . BankersRounding(28.2) = 28
140
140
141
- Throws errors with messages:
142
- - ** Expected an amount: ${amount})** : First argument isn't an ** Amount** .
141
+ Throws errors with messages:
142
+ - ** Expected an amount: ${amount})** : First argument isn't an ** Amount** .
143
143
- ** amount's brand ${q(amount.brand)} must match ratio's denominator ${q(
144
- ratio.denominator.brand** : The amount and ratio's denominator must have the same brand.
145
-
144
+ ratio.denominator.brand** : The amount and ratio's denominator must have the same brand.
145
+
146
146
``` js
147
147
const exchangeRatio = makeRatio (3n , swissFrancBrand, 5n , dollarBrand);
148
148
const dollars47 = AmountMath .make (dollarBrand, 47n );
@@ -169,10 +169,10 @@ would go
169
169
2 . 235 / 3 = 78.33333...
170
170
3 . Floor(78.3333...) = 78
171
171
172
- Throws errors with messages:
173
- - ** Expected an amount: ${amount})** : First argument isn't an ** Amount** .
174
- - ** amount's brand ${q(amount.brand)} must match ratio's numerator ${q(ratio.numerator.brand** : The
175
- amount and ratio's numerator must have the same brand.
172
+ Throws errors with messages:
173
+ - ** Expected an amount: ${amount})** : First argument isn't an ** Amount** .
174
+ - ** amount's brand ${q(amount.brand)} must match ratio's numerator ${q(ratio.numerator.brand** : The
175
+ amount and ratio's numerator must have the same brand.
176
176
177
177
``` js
178
178
const exchangeRatio = makeRatio (3n , swissFrancBrand, 5n , dollarBrand);
@@ -200,10 +200,10 @@ would go
200
200
2 . 235 / 3 = 78.33333...
201
201
3 . Ceiling(78.3333...) = 79
202
202
203
- Throws errors with messages:
204
- - ** Expected an amount: ${amount})** : First argument isn't an ** Amount** .
205
- - ** amount's brand ${q(amount.brand)} must match ratio's numerator ${q(ratio.numerator.brand** : The
206
- amount and ratio's numerator must have the same brand.
203
+ Throws errors with messages:
204
+ - ** Expected an amount: ${amount})** : First argument isn't an ** Amount** .
205
+ - ** amount's brand ${q(amount.brand)} must match ratio's numerator ${q(ratio.numerator.brand** : The
206
+ amount and ratio's numerator must have the same brand.
207
207
208
208
``` js
209
209
const exchangeRatio = makeRatio (3n , swissFrancBrand, 5n , dollarBrand);
@@ -231,10 +231,10 @@ would go
231
231
2 . 235 / 3 = 78.33333...
232
232
3 . BankersRounding(78.3333...) = 78
233
233
234
- Throws errors with messages:
235
- - ** Expected an amount: ${amount})** : First argument isn't an ** Amount** .
236
- - ** amount's brand ${q(amount.brand)} must match ratio's numerator ${q(ratio.numerator.brand** : The
237
- amount and ratio's numerator must have the same brand.
234
+ Throws errors with messages:
235
+ - ** Expected an amount: ${amount})** : First argument isn't an ** Amount** .
236
+ - ** amount's brand ${q(amount.brand)} must match ratio's numerator ${q(ratio.numerator.brand** : The
237
+ amount and ratio's numerator must have the same brand.
238
238
239
239
``` js
240
240
const exchangeRatio = makeRatio (3n , swissFrancBrand, 5n , dollarBrand);
@@ -273,11 +273,11 @@ denominator, and then the **Ratios** are added.
273
273
274
274
For example:
275
275
276
- 1 . Let's assume * left* = { numerator: 44n kilometers, denominator: 3n hours } and
277
- * right* = { numerator: 25n kilometers, denominator: 2n hours }.
278
- 2 . * left* would be multiplied by 2/2, and * right* would be multiplied by 3/3, resulting in
279
- * left* = { numerator: 88n kilometers, denominator: 6n hours } and * right* = { numerator: 75n kilometers, denominator: 6n hours }
280
- 3 . * left* and * right* would then be added together, resulting in { numerator: 163n kilometers, denominator: 6n hours }.
276
+ 1 . Let's assume * left* = { numerator: ` 44n ` kilometers, denominator: ` 3n ` hours } and
277
+ * right* = { numerator: ` 25n ` kilometers, denominator: ` 2n ` hours }.
278
+ 2 . * left* would be multiplied by 2/2, and * right* would be multiplied by 3/3, resulting in
279
+ * left* = { numerator: ` 88n ` kilometers, denominator: ` 6n ` hours } and * right* = { numerator: ` 75n ` kilometers, denominator: ` 6n ` hours }
280
+ 3 . * left* and * right* would then be added together, resulting in { numerator: ` 163n ` kilometers, denominator: ` 6n ` hours }.
281
281
This ** Ratio** would then be returned.
282
282
283
283
@@ -298,11 +298,11 @@ denominator, and then *right* is subtracted from *left*.
298
298
299
299
For example:
300
300
301
- 1 . Let's assume * left* = { numerator: 44n kilometers, denominator: 3n hours } and
302
- * right* = { numerator: 25n kilometers, denominator: 2n hours }.
303
- 2 . * left* would be multiplied by 2/2, and * right* would be multiplied by 3/3, resulting in
304
- * left* = { numerator: 88n kilometers, denominator: 6n hours } and * right* = { numerator: 75n kilometers, denominator: 6n hours }
305
- 3 . * right* would then be subtracted from * left* would then be added together, resulting in { numerator: 13n kilometers, denominator: 6n hours }.
301
+ 1 . Let's assume * left* = { numerator: ` 44n ` kilometers, denominator: ` 3n ` hours } and
302
+ * right* = { numerator: ` 25n ` kilometers, denominator: ` 2n ` hours }.
303
+ 2 . * left* would be multiplied by 2/2, and * right* would be multiplied by 3/3, resulting in
304
+ * left* = { numerator: ` 88n ` kilometers, denominator: ` 6n ` hours } and * right* = { numerator: ` 75n ` kilometers, denominator: ` 6n ` hours }
305
+ 3 . * right* would then be subtracted from * left* would then be added together, resulting in { numerator: ` 13n ` kilometers, denominator: ` 6n ` hours }.
306
306
This ** Ratio** would then be returned.
307
307
308
308
## multiplyRatios(left, right)
@@ -341,10 +341,10 @@ aren't identical.
341
341
- Returns: ** Boolean**
342
342
343
343
Returns ** true** if the * left* and * right* ** Ratios** are the same, ** false** otherwise. Note that for
344
- the two ** Ratios** to be considered the same, the
344
+ the two ** Ratios** to be considered the same, the
345
345
** [ AmountValue] ( /reference/ertp-api/ertp-data-types#amountvalue ) ** and ** [ Brand] ( /reference/ertp-api/brand ) **
346
346
of both the * numerator* and * denominator* of one ** Ratio** must be identical to the ** AmountValue** and
347
- ** Brand** of the * numerator* and * denominator* of the other ** Ratio** .
347
+ ** Brand** of the * numerator* and * denominator* of the other ** Ratio** .
348
348
349
349
350
350
## quantize(ratio, newDen)
0 commit comments