From 1b32779beeb9f4c96ebeae8ed7cb04e44002f837 Mon Sep 17 00:00:00 2001 From: Yarchik Date: Tue, 23 Jun 2026 02:06:34 +0100 Subject: [PATCH] fix(Unit): use the exact value for the acre unit The acre was stored as a rounded `4046.86 m2`, while its defining units `sqyd`, `sqft`, and `sqmi` are stored at full precision. An acre is defined as exactly 4840 square yards, so it is `4046.8564224 m2`. Because of the rounding, conversions were internally inconsistent: math.evaluate('1 acre to sqyd') // was 4840.004..., now exactly 4840 math.evaluate('1 acre to sqft') // was 43560.04..., now exactly 43560 Use the exact value. --- src/type/unit/Unit.js | 4 ++-- test/unit-tests/type/unit/Unit.test.js | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/type/unit/Unit.js b/src/type/unit/Unit.js index 87498385b0..bd80689dcf 100644 --- a/src/type/unit/Unit.js +++ b/src/type/unit/Unit.js @@ -1837,9 +1837,9 @@ export const createUnitClass = /* #__PURE__ */ factory(name, dependencies, ({ name: 'acre', base: BASE_UNITS.SURFACE, prefixes: PREFIXES.NONE, - value: 4046.86, + value: 4046.8564224, offset: 0 - }, // 4046.86 m2 + }, // 4046.8564224 m2 (4840 sqyd) hectare: { name: 'hectare', base: BASE_UNITS.SURFACE, diff --git a/test/unit-tests/type/unit/Unit.test.js b/test/unit-tests/type/unit/Unit.test.js index b8a2fe96a5..db029b4c77 100644 --- a/test/unit-tests/type/unit/Unit.test.js +++ b/test/unit-tests/type/unit/Unit.test.js @@ -1234,6 +1234,11 @@ describe('Unit', function () { assert.strictEqual(new Unit(1, 'kilogramforce').equals(new Unit(1, 'kgf')), true) }) + it('should define acre exactly as 4840 sqyd', function () { + assert.strictEqual(new Unit(1, 'acre').equals(new Unit(4840, 'sqyd')), true) + assert.strictEqual(new Unit(1, 'acre').equals(new Unit(43560, 'sqft')), true) + }) + it("For each built-in unit, 'name' should match key", function () { for (const key in Unit.UNITS) { if (hasOwnProperty(Unit.UNITS, key)) {