 ×
HIDE

# Available Mathematic Formulas for Calculated Field

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.

https://pafe.piotnet.com/docs/calculated-fields/

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

### 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:

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

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:

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.   