Available Calculated Field Mathematic Formulas

Available Calculated Field Mathematic Formulas

 

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.

Calculated Field

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.

———————————————————-

Arithmetic Operators

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).

In addition to the standard arithmetic operations (+, -, *, /), JavaScript provides the arithmetic operators: Remainder (%), Increment (++), Decrement (–), Unary negation (-), Unary plus (+), Exponentiation operator (**).

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”]

Bitwise Operators

A bitwise operator treats their operands as a set of 32 bits (zeros and ones), rather than as decimal, hexadecimal, or octal numbers. For example, the decimal number nine has a binary representation of 1001. Bitwise operators perform their operations on such binary representations, but they return standard JavaScript numerical values.

All Bitwise Operators: Bitwise AND, Bitwise OR, Bitwise XOR, Bitwise NOT, Left shift, Sign-propagating right shift, Zero-fill right shift.

For detail 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

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.

Unlike many other global objects, Math is not a constructor. All properties and methods of Math are static. You refer to the constant pi as Math.PI and you call the sine function as Math.sin(x), where x is the method’s argument. Constants are defined with the full precision of real numbers in JavaScript.

 

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:

  • abs([field id=”operandone”]-[field id=”operandtwo”]):

Return the absolute value of expression  [field id=”operandone”]-[field id=”operandtwo”]

  • acos( [field id=”operandone”]):

Return the arccosine of [field id=”operandone”]

  • 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.