SurveyMonkey Apply

How to Convert a Floating Point to an Integer (INT)

Using Advanced Expression Piping within your forms you can create mathematical formulas in order to calculate a value. This article will explain the process of using the INT function to convert a floating point to an integer. 

The INT function allows the expression to convert a floating point into an integer for either a single value or a list of values from a number of given fields. For example, if a value results in 1.0 we can use INT to convert it to 1.

Converting the value into an integer would allow the value to be used within a text response field using text field validations such as currency or integers (Positive Numbers).

The setup and formatting of the INT expression is imperative in preventing an error message from appearing on your form where the result of your expression would normally appear. The first line of the INT expression should be set up as follows:

{{ INT(variable1+variable2) }}
  • Each expression is always contained within a pair of double "curly" brackets {{  }}
  • There should be a space between the first instance of INT and the last bracket
  • Variables you are using are case sensitive. 
  • Always close each INT operation with brackets ( )

What's different about INT over some of the other functions is that INT can be used in conjunction with other functions. For example, using the AVG Function, if we want to calculate the average of 3 values, should that value return a floating point, INT can be used to ensure the value is a whole number. 

INT using addition{{ INT(q1[0]+q1[1]) }}Ensures that the sum of q1[0] and q1[1] displays a whole number.
INT using subtraction{{ INT(q2[1]-q1[0]) }}Ensures that the difference of q2[1] and q1[0] displays a whole number.
INT using multiplication{{ INT(q1[1]*2) }}           OR(( INT(q1[2]*q2[0]) }}Ensures the product of the multiplied values displays a whole number.
INT using division{{ INT(q1[3]/4) }}           OR{{ INT(q2[0]/q1[1]) }}Ensures the quotient of the divided values displays a whole number.
INT on another function{{ INT(SUM(q1[:0])) }}           OR{{ INT(AVG(q1[0],q1[2],[q1[3]) }}Ensure the result of the expression using another function displays a whole number.