diff --git a/src/helpers/format/format.ts b/src/helpers/format/format.ts index 448752e9d8..4c57770c96 100644 --- a/src/helpers/format/format.ts +++ b/src/helpers/format/format.ts @@ -800,7 +800,7 @@ function _createLargeNumberFormat( magnitude: number, postFix: string ): T { - if (format.type !== "number") { + if (format.type !== "number" || format.scientific) { return format; } diff --git a/tests/functions/module_custom.test.ts b/tests/functions/module_custom.test.ts index 871472939f..906753d4a9 100644 --- a/tests/functions/module_custom.test.ts +++ b/tests/functions/module_custom.test.ts @@ -1,6 +1,6 @@ import { Model } from "../../src"; import { setCellContent, setCellFormat, setFormat } from "../test_helpers/commands_helpers"; -import { getCellContent, getCellError } from "../test_helpers/getters_helpers"; +import { getCellContent, getCellError, getEvaluatedCell } from "../test_helpers/getters_helpers"; import { evaluateCellText } from "../test_helpers/helpers"; describe("FORMAT.LARGE.NUMBER formula", () => { @@ -171,6 +171,17 @@ describe("FORMAT.LARGE.NUMBER formula", () => { expect(getCellContent(model, "A2")).toBe("5,000m"); }); + test("FORMAT.LARGE.NUMBER does nothing on numbers with scientific format", () => { + const model = new Model(); + setCellContent(model, "A1", "100000"); + setFormat(model, "A1", "0e"); + setCellContent(model, "A2", "=FORMAT.LARGE.NUMBER(A1)"); + expect(getCellContent(model, "A2")).toBe("1e+05"); + + setFormat(model, "A1", "0;0e;-0e;@[$Hello]"); + expect(getEvaluatedCell(model, "A2").format).toBe("0,[$k];0e;-0e;@[$Hello]"); + }); + test("Percentage in decimal part is preserved by FORMAT.LARGE.NUMBER", () => { const model = new Model(); setCellContent(model, "A1", "100000");