Skip to content
This repository was archived by the owner on Jan 15, 2025. It is now read-only.

Commit d111462

Browse files
committed
Remove more dead code
1 parent e97fb97 commit d111462

File tree

1 file changed

+4
-96
lines changed

1 file changed

+4
-96
lines changed

src/Decimal128.mts

+4-96
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@ import { Rational } from "./Rational.mjs";
2323
import { Decimal } from "./Decimal.mjs";
2424

2525
const EXPONENT_MIN = -6176;
26-
const NORMAL_EXPONENT_MIN = -6143;
2726
const EXPONENT_MAX = 6111;
28-
const NORMAL_EXPONENT_MAX = 6144;
2927
const MAX_SIGNIFICANT_DIGITS = 34;
3028

3129
const bigTen = BigInt(10);
@@ -53,6 +51,10 @@ function pickQuantum(
5351
return EXPONENT_MAX;
5452
}
5553

54+
if (d === "0" || d === "-0") {
55+
return preferredQuantum;
56+
}
57+
5658
return preferredQuantum;
5759
}
5860

@@ -542,36 +544,6 @@ export class Decimal128 {
542544
return p + lhs + "." + rhs.substring(0, n) + "e" + exp;
543545
}
544546

545-
private isInteger(): boolean {
546-
let s = this.toString();
547-
548-
let [_, rhs] = s.split(/[.]/);
549-
550-
if (rhs === undefined) {
551-
return true;
552-
}
553-
554-
return !!rhs.match(/^0+$/);
555-
}
556-
557-
toBigInt(): bigint {
558-
if (this.isNaN()) {
559-
throw new RangeError("NaN cannot be converted to a BigInt");
560-
}
561-
562-
if (!this.isFinite()) {
563-
throw new RangeError("Infinity cannot be converted to a BigInt");
564-
}
565-
566-
if (!this.isInteger()) {
567-
throw new RangeError(
568-
"Non-integer decimal cannot be converted to a BigInt"
569-
);
570-
}
571-
572-
return BigInt(this.toString());
573-
}
574-
575547
toNumber(): number {
576548
if (this.isNaN()) {
577549
return NaN;
@@ -1074,70 +1046,6 @@ export class Decimal128 {
10741046
let q = this.divide(d).round(0, ROUNDING_MODE_TRUNCATE);
10751047
return this.subtract(d.multiply(q));
10761048
}
1077-
1078-
isNormal(): boolean {
1079-
if (this.isNaN()) {
1080-
throw new RangeError("Cannot determine whether NaN is normal");
1081-
}
1082-
1083-
if (!this.isFinite()) {
1084-
throw new RangeError(
1085-
"Only finite numbers can be said to be normal or not"
1086-
);
1087-
}
1088-
1089-
if (this.isZero()) {
1090-
throw new RangeError(
1091-
"Only non-zero numbers can be said to be normal or not"
1092-
);
1093-
}
1094-
1095-
let exp = this.exponent();
1096-
return exp >= NORMAL_EXPONENT_MIN && exp <= NORMAL_EXPONENT_MAX;
1097-
}
1098-
1099-
isSubnormal(): boolean {
1100-
if (this.isNaN()) {
1101-
throw new RangeError("Cannot determine whether NaN is subnormal");
1102-
}
1103-
1104-
if (!this.isFinite()) {
1105-
throw new RangeError(
1106-
"Only finite numbers can be said to be subnormal or not"
1107-
);
1108-
}
1109-
1110-
let exp = this.exponent();
1111-
return exp < NORMAL_EXPONENT_MIN;
1112-
}
1113-
1114-
truncatedExponent(): number {
1115-
if (this.isZero() || this.isSubnormal()) {
1116-
return NORMAL_EXPONENT_MIN;
1117-
}
1118-
1119-
return this.exponent();
1120-
}
1121-
1122-
scaledSignificand(): bigint {
1123-
if (this.isNaN()) {
1124-
throw new RangeError("NaN does not have a scaled significand");
1125-
}
1126-
1127-
if (!this.isFinite()) {
1128-
throw new RangeError("Infinity does not have a scaled significand");
1129-
}
1130-
1131-
if (this.isZero()) {
1132-
return 0n;
1133-
}
1134-
1135-
let v = this.cohort() as Rational;
1136-
let te = this.truncatedExponent();
1137-
let ss = v.scale10(MAX_SIGNIFICANT_DIGITS - 1 - te);
1138-
1139-
return ss.numerator;
1140-
}
11411049
}
11421050

11431051
Decimal128.prototype.valueOf = function () {

0 commit comments

Comments
 (0)