X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.spreadsheet.graph%2Fsrc%2Forg%2Fsimantics%2Fspreadsheet%2Fgraph%2Fformula%2FSqrtFormulaFunction.java;h=ae841568f5ddc926db73ef089e99a54395e7a686;hp=860379479c9d5a7405da0e2cd761a7600c22f535;hb=refs%2Fchanges%2F38%2F238%2F2;hpb=24e2b34260f219f0d1644ca7a138894980e25b14 diff --git a/bundles/org.simantics.spreadsheet.graph/src/org/simantics/spreadsheet/graph/formula/SqrtFormulaFunction.java b/bundles/org.simantics.spreadsheet.graph/src/org/simantics/spreadsheet/graph/formula/SqrtFormulaFunction.java index 860379479..ae841568f 100644 --- a/bundles/org.simantics.spreadsheet.graph/src/org/simantics/spreadsheet/graph/formula/SqrtFormulaFunction.java +++ b/bundles/org.simantics.spreadsheet.graph/src/org/simantics/spreadsheet/graph/formula/SqrtFormulaFunction.java @@ -1,21 +1,21 @@ -package org.simantics.spreadsheet.graph.formula; - -import org.simantics.spreadsheet.graph.CellFormulaFunction; -import org.simantics.spreadsheet.graph.CellValueVisitor; -import org.simantics.spreadsheet.graph.SpreadsheetGraphUtils; -import org.simantics.spreadsheet.graph.parser.ast.AstArgList; - -public class SqrtFormulaFunction implements CellFormulaFunction { - - @Override - public Object evaluate(CellValueVisitor visitor, AstArgList args) { - if (args.values.size() != 1) throw new IllegalStateException(); - - Object number = args.values.get(0).accept(visitor); - Double dVal = SpreadsheetGraphUtils.asDoubleWhereEmptyStringIsZero(number); - if(dVal==null) return FormulaError2.handleErrorCall(number); - if(dVal<0) return FormulaError2.NUM.getString(); - - return Math.sqrt(dVal); - } -} +package org.simantics.spreadsheet.graph.formula; + +import org.simantics.spreadsheet.graph.CellFormulaFunction; +import org.simantics.spreadsheet.graph.CellValueVisitor; +import org.simantics.spreadsheet.graph.SpreadsheetGraphUtils; +import org.simantics.spreadsheet.graph.parser.ast.AstArgList; + +public class SqrtFormulaFunction implements CellFormulaFunction { + + @Override + public Object evaluate(CellValueVisitor visitor, AstArgList args) { + if (args.values.size() != 1) throw new IllegalStateException(); + + Object number = args.values.get(0).accept(visitor); + Double dVal = SpreadsheetGraphUtils.asDoubleWhereEmptyStringIsZero(number); + if(dVal==null) return FormulaError2.handleErrorCall(number); + if(dVal<0) return FormulaError2.NUM.getString(); + + return Math.sqrt(dVal); + } +}