Calculated field is a powerful feature of Piotnet which helps you to do mathematic formulas in forms. The feature is widely applied in quotation generating.
This document is not a guidance of how to setup calculated field in your forms. Instead, we will show you the available operators and object that the field can perform.
Detailed Mathematic Formulas
An arithmetic operator takes numerical values (either literals or variables) as their operands and returns a single numerical value. The standard arithmetic operators are addition (+), subtraction (-), multiplication (*), and division (/). These operators work as they do in most other programming languages when used with floating point numbers (in particular, note that division by zero produces Infinity).
For detail description of the operator, please see the full document here: Arithmetic operators
Example formula in Piotnet:
- Addition: [field id=”operandone”]+[field id=”operandtwo”]
- Division: [field id=”operanda”]+[field id=”operandb”]
- Remainder: [field id=”operanda”]%[field id=”operandb”]
All Bitwise Operators: Bitwise AND, Bitwise OR, Bitwise XOR, Bitwise NOT, Left shift, Sign-propagating right shift, Zero-fill right shift.
For detailed description of the operator, please see the full document here: Bitwise operators
Usage in Piotnet:
- Multiplied by the m-th power of 2: [field id=”n”]<<[field id=”m”]
- Divided by the m-th power of 2: [field id=”n”]>>[field id=”m”]
- Calculate 2^n: 2 << ([field id=”n”]-1)
Math is a built-in object that has properties and methods for mathematical constants and functions. It’s not a function object.
Math works with the Number type. It doesn’t work with BigInt.
A list of available Math Static Methods in Piotnet:
Math.abs(x), Math.acos(x), Math.acosh(x), Math.asin(x), Math.asinh(x), Math.atan(x), Math.atanh(x), Math.atan2(y, x), Math.cbrt(x), Math.ceil(x), Math.clz32(x), Math.cos(x), Math.cosh(x), Math.exp(x), Math.expm1(x), Math.floor(x), Math.fround(x), Math.hypot([x[, y[, …]]]), Math.imul(x, y), Math.log(x), Math.log1p(x), Math.log10(x), Math.log2(x), Math.max([x[, y[, …]]]), Math.min([x[, y[, …]]]), Math.pow(x, y), Math.random(), Math.round(x), Math.sign(x), Math.sin(x), Math.sinh(x), Math.sqrt(x), Math.tan(x), Math.tanh(x), Math.trunc(x).
For detail description of the operator, please see the full document here: Math.
Example in Piotnet:
- Math.abs([field id=”operandone”]-[field id=”operandtwo”]):
Return the absolute value of expression [field id=”operandone”]-[field id=”operandtwo”]
- Math.acos( [field id=”operandone”]):
Return the arccosine of [field id=”operandone”]
- Math.ceil( [field id=”operandone”]):
Returns the smallest integer greater than or equal to [field id=”operandone”]
We hope this guidance is useful for your work in setup complicated and functional forms.