gn:act_calculate
- Description
- Action used to perform calculation operations on different actors and stores result in target.
- If calculations with trigonometric functions give the wrong results, please note that the trigonometric variables input is expressed in radians, not degrees
- By default, the format of calculation result on
GnEditText
is set to0.00
.
- If the result needs to be formatted differently, check attribute
gn:s_decimalFormat
onGnEditText
- Action returns
- void
Available operands
Operand Example Addition 2 + 2 Subtraction 2 - 2 Multiplication 2 * 2 Division 2 / 2 Exponentation 2 ^ 2 Unary Minus,Plus (Sign Operators) +2 - (-2) Modulo 2 % 2
Available functions
Function Description abs absolute value acos arc cosine asin arc sine atan arc tangent cbrt cubic root ceil nearest upper integer cos cosine cosh hyperbolic cosine exp euler's number raised to the power (e^x) floor nearest lower integer log logarithmus naturalis (base e) log10 logarithm (base 10) log2 logarithm (base 2) sin sine sinh hyperbolic sine sqrt square root tan tangent tanh hyperbolic tangent
Action signatures
Calculate result into target widget
[gn:act_calculate]|[target,calculationFormula]
Parameter Description target
target from where the while action is using value as expression parameter - Valid targets:
calculationFormula
represents formula to be calculated - WidgetId’s, String resources or ginstr app variables can be used to replace variable placeholders in the equation,
- i.e.
3*sin(@+id/widgetId)-2(@+variable/varId-2)
.
- i.e.
- All values in actors should be numeric or they will be ignored in calculation
- Actors that can be used as calculation variables:
- string resources
Example
Calculate with operand
@variable/myResultVar
- target where the calculation result will be stored@+id/widgetOne*@variable/calcVarOne
- calculation formula
- ⤷
[gn:act_calculate]|[@variable/myResultVar,@+id/widgetOne*@variable/calcVarOne]
- ⤷
Calculate with function
@variable/tour_scheduledTourStartMinutesNumber
- target where the calculation result will be storedfloor((@variable/tour_scheduledTourStartDecimal%1)*60)
- calculation formula with floor function
- ⤷
[gn:act_calculate]|[@variable/tour_scheduledTourStartMinutesNumber,floor((@variable/tour_scheduledTourStartDecimal%1)*60)]
- ⤷