Back to List
Placeholder | Replace With |
num | A number value, such as a Number variable |
num | A number value specifying the number of places (0-7) to the right of the decimal point at which to truncate the number |
You can truncate a decimal number a specified number of places after a decimal point.
For example, the following script truncates the number 5.9375 to include only the first two digits after the decimal point. The truncated value is 5.93:
truncate( 5.9375, 2 )
In the next example, however, a Computation variable tests if the value of RentAmount includes cents. The variable is then formatted to eliminate the text AND NO CENTS from being merged when the variable contains only a whole number:
if RentAmount = TRUNCATE( RentAmount, 0 )
format( RentAmount, "NINE DOLLARS" )
else
format( RentAmount, "NINE DOLLARS AND TWELVE CENTS" )
endIf
Specifically, this computation compares the actual value of RentAmount against its truncated value. If the values are equal, HotDocs formats the answer to exclude the text, AND TWELVE CENTS. Otherwise it includes the text in the format.
The difference between the truncate and the round expressions is that truncate simply "cuts off" a number at a specified digit, while round actually rounds a number up or down, based on where you want the number rounded.
Back to List