NpsFormula is a library for evaluating various mathematical expressions.
|
NpsFormula(String expression) Constructor |
|
| void |
SetExpression(String expression) Set expression to evaluate |
| void |
AddSymbol(String symbol,Object value) Add variable |
| void |
RemoveSymbol(String symbol) Remove variable |
| String |
Evaluate() Evaluate |
| SUM |
Adds all the numbers in a range of cells. SUM(number1,number2, ...) Number1, number2, ... are arguments for which you want the total value or sum. =SUM(3, 2) Adds 3 and 2 (5) |
| average |
Returns the average (arithmetic mean) of the arguments. AVERAGE(number1,number2,...) Number1, number2, ... are arguments for which you want the average. =AVERAGE(10,7,9,27,2) Average of the numbers above (11) |
| max |
Returns the largest value in a set of values. MAX(number1,number2,...) Number1, number2, ... are numbers for which you want to find the maximum =MAX(10,7,9,27,2) Largest of the numbers above (27) |
| min | Returns the smallest number in a set of values. MIN(number1,number2,...) Number1, number2, ... are numbers for which you want to find the minimum =MIN(10,7,9,27,2) Smallest of the numbers above (2) |
| abs |
Returns the absolute value of a number. The absolute value of a number is the number without its sign. ABS(number) Number is the real number of which you want the absolute value. =ABS(-2) Absolute value of -2 (2) |
| mod |
Returns the remainder after number is divided by divisor. The result has the same sign as divisor. MOD(number,divisor) Number is the number for which you want to find the remainder. Divisor is the number by which you want to divide number. =MOD(3, 2) Remainder of 3/2 (1) |
| int |
Rounds a number down to the nearest integer. INT(number) Number is the real number you want to round down to an integer. =INT(8.9) Rounds 8.9 down (8) =INT(-8.9) Rounds -8.9 down (-9) |
| round |
Rounds a number to a specified number of digits. ROUND(number,num_digits) Number is the number you want to round. Num_digits specifies the number of digits to which you want to round number. =ROUND(2.15, 1) Rounds 2.15 to one decimal place (2.2) |
| trunc |
Truncates a number to an integer by removing the fractional part of the number. TRUNC(number,num_digits) Number is the number you want to truncate. Num_digits is a number specifying the precision of the truncation. The default value for num_digits is 0 (zero). =TRUNC(8.9) Integer part of 8.9 (8) |
| cos |
Returns the cosine of the given angle. COS(number) Number is the angle in radians for which you want the cosine. =COS(60*PI()/180) Cosine of 60 degrees (0.5) |
| sin |
Returns the sine of the given angle. SIN(number) Number is the angle in radians for which you want the sine. =SIN(PI()/2) Sine of pi/2 radians (1) |
| tan |
Returns the tangent of the given angle. TAN(number) Number is the angle in radians for which you want the tangent. =TAN(45*PI()/180) Tangent of 45 degrees (1) |
| acos |
Returns the arccosine, or inverse cosine, of a number. The arccosine is the angle whose cosine is number. The returned angle is given in radians in the range 0 (zero) to pi. ACOS(number) Number is the cosine of the angle you want and must be from -1 to 1. =ACOS(-0.5)*180/PI() Arccosine of -0.5 in degrees (120) |
| asin |
Returns the arcsine, or inverse sine, of a number. The arcsine is the angle whose sine is number. The returned angle is given in radians in the range -pi/2 to pi/2. ASIN(number) Number is the sine of the angle you want and must be from -1 to 1. =ASIN(-0.5)*180/PI() Arcsine of -0.5 in degrees (-30) |
| atan |
Returns the arctangent, or inverse tangent, of a number. The arctangent is the angle whose tangent is number. The returned angle is given in radians in the range -pi/2 to pi/2. ATAN (number) Number is the tangent of the angle you want. =ATAN(1)*180/PI() Arctangent of 1 in degrees (45) |
| if |
Returns one value if a condition you specify evaluates to TRUE and another value if it evaluates to FALSE.
IF(logical_test,value_if_true,value_if_false) Logical_test is any value or expression that can be evaluated to TRUE or FALSE. This argument can use any comparison calculation operator. Value_if_true is the value that is returned if logical_test is TRUE. Value_if_true can be another formula. Value_if_false is the value that is returned if logical_test is FALSE. Value_if_false can be another formula. =IF(BUDGET<=100,"Within budget","Over budget") If the variable "BUGDGET" is less than or equal to 100, then the formula displays "Within budget". Otherwise, the function displays "Over budget" (Within budget) |
| or |
Returns TRUE if any argument is TRUE; returns FALSE if all arguments are FALSE.
OR(logical1,logical2,...) Logical1,logical2,... are conditions you want to test that can be either TRUE or FALSE. =OR(1+1=1,2+2=5) All arguments evaluate to FALSE (FALSE) |
| and |
Returns TRUE if all its arguments are TRUE; returns FALSE if one or more argument is FALSE.
AND(logical1,logical2, ...) Logical1, logical2, ... are conditions you want to test that can be either TRUE or FALSE. =AND(TRUE, FALSE) One argument is FALSE (FALSE) |
| PI | Returns the number 3.1415926535897931, the mathematical constant pi, accurate to 16 digits. |
| E | Returns the number 2.7182818284590451, the mathematical constant E, accurate to 16 digits. |