f7
f7 is a spreadsheet formula execution library
git clone https://git.vogt.world/f7.git
Log | Files | README.md | LICENSE.md
← All files
name: src/main/js/formulas/math/UMINUS.ts
-rw-r--r--
819
 1import { F7Exception } from "../../errors/F7Exception";
 2import { SheetColumnRowKey } from "../../models/common/SheetColumnRowKey";
 3import { Complex } from "../../models/common/Types";
 4import { Converters } from "../../utils/Converters";
 5import { AbstractFormula } from "../AbstractFormula";
 6import { FormulaName } from "../FormulaName";
 7
 8export class UMINUS extends AbstractFormula {
 9  static SELF: UMINUS = new UMINUS();
10  NAME = FormulaName.UMINUS;
11
12  internal(origin: SheetColumnRowKey, ...values: Array<Complex>) {
13    AbstractFormula.checkLength(values.length, 1, this.NAME);
14    const value = Converters.first(this.collateralLookup(origin, values[0]));
15    if (value instanceof F7Exception) {
16      return value;
17    }
18    const n = Converters.toNumber(value);
19    return Converters.toPositiveZero(n * -1);
20  }
21}