name:
src/main/js/formulas/math/UNARY_PERCENT.ts
-rw-r--r--
805
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 UNARY_PERCENT extends AbstractFormula {
9 static SELF: UNARY_PERCENT = new UNARY_PERCENT();
10 NAME = FormulaName.UNARY_PERCENT;
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 return Converters.toNumber(value) * 0.01;
19 }
20}