Remove the 0 Before a Decimal Point

From HotDocs Wiki

Jump to: navigation, search

When merging numbers with decimal places in your templates, a number less than 1 will include a zero (0) before the decimal point by default. If you want to remove the zero, you can use the following computation.

This computation removes the preceding 0 for all numbers between -1 and 1. (Numbers that do not fall within this range are not preceded by zero anyway.) For example, if the answer for Num Var is 0.50, this computation formats the answer as .50 instead of 0.50.


IF Num Var > -1 AND Num Var < 0
  "-." + FORMAT( ABSOLUTE VALUE( Num Var ) * 100, "09" )
ELSE IF Num Var > 0 AND Num Var < 1
  "." + FORMAT( Num Var * 100, "09" )
  FORMAT( Num Var, "9.00" )

Num Var Any Number variable with two decimal places. (If your variable has a different number of decimal places, you must modify the script accordingly.)