dmolony-DiskBrowser/src/com/bytezone/diskbrowser/visicalc/Sqrt.java
2017-03-19 08:23:44 +11:00

31 lines
626 B
Java

package com.bytezone.diskbrowser.visicalc;
public class Sqrt extends Function
{
private final Value source;
Sqrt (Cell cell, String text)
{
super (cell, text);
assert text.startsWith ("@SQRT(") : text;
source = new Expression (parent, cell, functionText).reduce ();
values.add (source);
}
@Override
public void calculate ()
{
source.calculate ();
if (!source.isValueType (ValueType.VALUE))
{
valueType = source.getValueType ();
return;
}
value = Math.sqrt (source.getValue ());
valueType = Double.isNaN (value) ? ValueType.ERROR : ValueType.VALUE;
}
}