diff --git a/packages/bignumber/src.ts/fixednumber.ts b/packages/bignumber/src.ts/fixednumber.ts index 54ed796336..131a88654d 100644 --- a/packages/bignumber/src.ts/fixednumber.ts +++ b/packages/bignumber/src.ts/fixednumber.ts @@ -120,6 +120,12 @@ export class FixedFormat { readonly _multiplier: string; constructor(constructorGuard: any, signed: boolean, width: number, decimals: number) { + if (constructorGuard !== _constructorGuard) { + logger.throwError("cannot use FixedFormat construtor; use FixedFormat.from", Logger.errors.UNSUPPORTED_OPERATION, { + operation: "new FixedFormat" + }); + } + this.signed = signed; this.width = width; this.decimals = decimals; @@ -185,6 +191,12 @@ export class FixedNumber { constructor(constructorGuard: any, hex: string, value: string, format?: FixedFormat) { logger.checkNew(new.target, FixedNumber); + if (constructorGuard !== _constructorGuard) { + logger.throwError("cannot use FixedNumber construtor; use FixedNumber.from", Logger.errors.UNSUPPORTED_OPERATION, { + operation: "new FixedFormat" + }); + } + this.format = format; this._hex = hex; this._value = value; @@ -247,6 +259,10 @@ export class FixedNumber { return FixedNumber.fromString(comps[0] + "." + comps[1].substring(0, decimals)); } + isZero(): boolean { + return (this._value === "0.0"); + } + toString(): string { return this._value; }