2016-03-15 04:40:57 +00:00
|
|
|
package com.bytezone.diskbrowser.visicalc;
|
|
|
|
|
|
|
|
public class Abs extends Function
|
|
|
|
{
|
2017-03-18 21:23:44 +00:00
|
|
|
private final Value source;
|
2017-02-25 03:56:22 +00:00
|
|
|
|
2017-03-18 08:33:40 +00:00
|
|
|
Abs (Cell cell, String text)
|
2016-03-15 04:40:57 +00:00
|
|
|
{
|
2017-03-18 08:33:40 +00:00
|
|
|
super (cell, text);
|
2017-03-03 23:41:08 +00:00
|
|
|
|
2017-03-18 09:21:11 +00:00
|
|
|
assert text.startsWith ("@ABS(") : text;
|
|
|
|
|
2017-03-18 21:23:44 +00:00
|
|
|
source = new Expression (parent, cell, functionText).reduce ();
|
2017-03-03 23:41:08 +00:00
|
|
|
values.add (source);
|
2016-03-15 04:40:57 +00:00
|
|
|
}
|
|
|
|
|
2016-03-15 20:06:04 +00:00
|
|
|
@Override
|
2017-02-28 20:39:26 +00:00
|
|
|
public void calculate ()
|
2016-03-15 04:40:57 +00:00
|
|
|
{
|
2017-03-03 23:41:08 +00:00
|
|
|
source.calculate ();
|
2017-02-25 03:56:22 +00:00
|
|
|
|
2017-03-18 21:23:44 +00:00
|
|
|
if (!source.isValueType (ValueType.VALUE))
|
|
|
|
{
|
|
|
|
valueType = source.getValueType ();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-02-25 03:56:22 +00:00
|
|
|
value = Math.abs (source.getValue ());
|
2017-03-18 21:23:44 +00:00
|
|
|
valueType = Double.isNaN (value) ? ValueType.ERROR : ValueType.VALUE;
|
2016-03-15 04:40:57 +00:00
|
|
|
}
|
|
|
|
}
|