name:
src/main/js/formulas/math/ACOS.ts
-rw-r--r--
870
1import { NumException } from "../../errors/NumException";
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 ACOS extends AbstractFormula {
9 static SELF: ACOS = new ACOS();
10 NAME = FormulaName.ACOS;
11
12 internal(origin: SheetColumnRowKey, ...values: Array<Complex>) {
13 AbstractFormula.checkLength(values.length, 1, this.NAME);
14 const n = Converters.toNumber(Converters.first(this.collateralLookup(origin, values[0])));
15 if (n < -1 || n > 1) {
16 return new NumException(
17 `Function ACOS parameter 1 value is ${n}. Valid values are between -1 and 1 inclusive.`
18 );
19 }
20 return Math.acos(n);
21 }
22}