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/ISODD.ts
-rw-r--r--
781
 1import { SheetColumnRowKey } from "../../models/common/SheetColumnRowKey";
 2import { Complex } from "../../models/common/Types";
 3import { Converters } from "../../utils/Converters";
 4import { AbstractFormula } from "../AbstractFormula";
 5import { FormulaName } from "../FormulaName";
 6import { ROUNDDOWN } from "./ROUNDDOWN";
 7
 8export class ISODD extends AbstractFormula {
 9  static SELF: ISODD = new ISODD();
10  NAME = FormulaName.ISODD;
11
12  internal(origin: SheetColumnRowKey, ...values: Array<Complex>) {
13    AbstractFormula.checkLength(values.length, 1, this.NAME);
14    const value = Converters.toNumber(Converters.first(this.collateralLookup(origin, values[0])));
15    const rounded = Converters.toNumber(ROUNDDOWN.SELF.run(null, value));
16    return Math.abs(rounded % 2) === 1;
17  }
18}