Skip to content

Commit 97207d1

Browse files
committed
fix Decimal code
1 parent 60076a1 commit 97207d1

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

packages/math/src/decimal.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ export class Decimal {
127127

128128
/** Returns the greatest decimal <= this which has no fractional part (rounding down) */
129129
public floor(): Decimal {
130-
const factor = 10n ** BigNum(this.data.fractionalDigits);
130+
const factor = 10n ** BigInt(this.data.fractionalDigits);
131131
const whole = this.data.atomics / factor;
132132
const fractional = this.data.atomics % factor;
133133

@@ -195,7 +195,7 @@ export class Decimal {
195195
public minus(b: Decimal): Decimal {
196196
if (this.fractionalDigits !== b.fractionalDigits) throw new Error("Fractional digits do not match");
197197
const difference = this.data.atomics - b.data.atomics;
198-
if (difference.ltn(0)) throw new Error("Difference must not be negative");
198+
if (difference < 0n) throw new Error("Difference must not be negative");
199199
return new Decimal(difference.toString(), this.fractionalDigits);
200200
}
201201

@@ -205,7 +205,7 @@ export class Decimal {
205205
* We only allow multiplication by unsigned integers to avoid rounding errors.
206206
*/
207207
public multiply(b: Uint32 | Uint53 | Uint64): Decimal {
208-
const product = this.data.atomics * b.toBigInt());
208+
const product = this.data.atomics * b.toBigInt();
209209
return new Decimal(product.toString(), this.fractionalDigits);
210210
}
211211

0 commit comments

Comments
 (0)