Skip to content

Commit 47e40bc

Browse files
authored
Merge pull request #1204 from Agoric/ratio-math-hydration-debug
fix: Ratio Math page partially rendering
2 parents 7f9fec0 + 4d181e4 commit 47e40bc

File tree

1 file changed

+40
-40
lines changed

1 file changed

+40
-40
lines changed

main/reference/zoe-api/ratio-math.md

+40-40
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Throws an error if the argument is not a valid **Ratio**.
1313

1414
Throws messages for errors:
1515
- **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)}**
1717

1818
```js
1919
assertIsRatio(aRatio);
@@ -23,12 +23,12 @@ assertIsRatio(aRatio);
2323
- **numerator**: **BigInt**
2424
- **numeratorBrand**: **[Brand](/reference/ertp-api/brand)**
2525
- **denominator**: **BigInt** - Optional, defaults to 100n.
26-
- **denominatorBrand)**: **Brand** - Optional, defaults to the *numeratorBrand* value.
26+
- **denominatorBrand**: **Brand** - Optional, defaults to the *numeratorBrand* value.
2727
- Returns: **[Ratio](./zoe-data-types#ratio)**
2828

2929
Returns a **Ratio** based on the arguments passed into the function.
3030

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).
3232

3333
```js
3434
// Use default values to create a ratio of 50 / 100 Quatloos
@@ -42,7 +42,7 @@ const ratio = makeRatio(75n, quatloosBrand, 4n, moolasBrand);
4242
- **denominatorAmount**: **Amount**
4343
- Returns: **[Ratio](./zoe-data-types#ratio)**
4444

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
4646
of two **Amounts**. The *numeratorAmount* is the **Ratio's** numerator and
4747
the *denominatorAmount* is the **Ratio's** denominator.
4848

@@ -73,11 +73,11 @@ would go
7373
2. 141 / 5 = 28.2
7474
3. Floor(28.2) = 28
7575

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**.
7878
- **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+
8181
```js
8282
const exchangeRatio = makeRatio(3n, swissFrancBrand, 5n, dollarBrand);
8383
const dollars47 = AmountMath.make(dollarBrand, 47n);
@@ -106,11 +106,11 @@ would go
106106
2. 141 / 5 = 28.2
107107
3. Ceiling(28.2) = 29
108108

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**.
111111
- **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+
114114
```js
115115
const exchangeRatio = makeRatio(3n, swissFrancBrand, 5n, dollarBrand);
116116
const dollars47 = AmountMath.make(dollarBrand, 47n);
@@ -138,11 +138,11 @@ would go
138138
2. 141 / 5 = 28.2
139139
3. BankersRounding(28.2) = 28
140140

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**.
143143
- **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+
146146
```js
147147
const exchangeRatio = makeRatio(3n, swissFrancBrand, 5n, dollarBrand);
148148
const dollars47 = AmountMath.make(dollarBrand, 47n);
@@ -169,10 +169,10 @@ would go
169169
2. 235 / 3 = 78.33333...
170170
3. Floor(78.3333...) = 78
171171

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.
176176

177177
```js
178178
const exchangeRatio = makeRatio(3n, swissFrancBrand, 5n, dollarBrand);
@@ -200,10 +200,10 @@ would go
200200
2. 235 / 3 = 78.33333...
201201
3. Ceiling(78.3333...) = 79
202202

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.
207207

208208
```js
209209
const exchangeRatio = makeRatio(3n, swissFrancBrand, 5n, dollarBrand);
@@ -231,10 +231,10 @@ would go
231231
2. 235 / 3 = 78.33333...
232232
3. BankersRounding(78.3333...) = 78
233233

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.
238238

239239
```js
240240
const exchangeRatio = makeRatio(3n, swissFrancBrand, 5n, dollarBrand);
@@ -273,11 +273,11 @@ denominator, and then the **Ratios** are added.
273273

274274
For example:
275275

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 }.
281281
This **Ratio** would then be returned.
282282

283283

@@ -298,11 +298,11 @@ denominator, and then *right* is subtracted from *left*.
298298

299299
For example:
300300

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 }.
306306
This **Ratio** would then be returned.
307307

308308
## multiplyRatios(left, right)
@@ -341,10 +341,10 @@ aren't identical.
341341
- Returns: **Boolean**
342342

343343
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
345345
**[AmountValue](/reference/ertp-api/ertp-data-types#amountvalue)** and **[Brand](/reference/ertp-api/brand)**
346346
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**.
348348

349349

350350
## quantize(ratio, newDen)

0 commit comments

Comments
 (0)