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

Commit 02c0f5a

Browse files
committed
Use proper rounding name
1 parent 5ead135 commit 02c0f5a

File tree

3 files changed

+29
-4
lines changed

3 files changed

+29
-4
lines changed

src/decimal128.mts

-2
Original file line numberDiff line numberDiff line change
@@ -460,8 +460,6 @@ function adjustNonInteger(
460460
options: FullySpecifiedConstructorOptions
461461
): SignedSignificandExponent {
462462
switch (options.roundingMode) {
463-
case ROUNDING_MODE_HALF_EVEN:
464-
return roundHalfEven(x);
465463
case ROUNDING_MODE_CEILING:
466464
return roundCeiling(x);
467465
case ROUNDING_MODE_FLOOR:

tests/constructor.test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ describe("rounding options", () => {
466466
roundTowardNegative: "-1234567890123456789012345678901235",
467467
roundTowardZero: "-1234567890123456789012345678901234",
468468
roundTiesToEven: "-1234567890123456789012345678901234",
469-
roundTiesAway: "-1234567890123456789012345678901234",
469+
roundTiesToAway: "-1234567890123456789012345678901235",
470470
};
471471
for (const [mode, expected] of Object.entries(answers)) {
472472
test(`constructor with rounding mode "${mode}"`, () => {
@@ -483,7 +483,7 @@ describe("rounding options", () => {
483483
roundTowardNegative: "-1234567890123456789012345678901240",
484484
roundTowardZero: "-1234567890123456789012345678901239",
485485
roundTiesToEven: "-1234567890123456789012345678901240",
486-
roundTiesAway: "-1234567890123456789012345678901240",
486+
roundTiesToAway: "-1234567890123456789012345678901240",
487487
};
488488
for (const [mode, expected] of Object.entries(roundUpAnswers)) {
489489
test(`constructor with rounding mode "${mode}"`, () => {

tests/round.test.js

+27
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,33 @@ describe("Intl.NumberFormat examples", () => {
166166
).toStrictEqual("1");
167167
});
168168
});
169+
describe("halfExpand", () => {
170+
test("-1.5", () => {
171+
expect(
172+
minusOnePointFive.round(0, "roundTiesToAway").toString()
173+
).toStrictEqual("-2");
174+
});
175+
test("0.4", () => {
176+
expect(
177+
zeroPointFour.round(0, "roundTiesToAway").toString()
178+
).toStrictEqual("0");
179+
});
180+
test("0.5", () => {
181+
expect(
182+
zeroPointFive.round(0, "roundTiesToAway").toString()
183+
).toStrictEqual("1");
184+
});
185+
test("0.6", () => {
186+
expect(
187+
zeroPointSix.round(0, "roundTiesToAway").toString()
188+
).toStrictEqual("1");
189+
});
190+
test("1.5", () => {
191+
expect(
192+
onePointFive.round(0, "roundTiesToAway").toString()
193+
).toStrictEqual("2");
194+
});
195+
});
169196
describe("halfEven", () => {
170197
test("-1.5", () => {
171198
expect(

0 commit comments

Comments
 (0)