|The HotDocs Computation Archive|
ROUND( ( ( NumberVar + 499 ) / 1000 ) ), 0 ) * 1000 Alternative: IF REMAINDER( NumberVar, 1000 ) ( ( TRUNCATE( ( NumberVar / 1000 ), 0 ) ) + 1 ) * 1000 ELSE ( ROUND( ( NumberVar / 1000 ), 0 ) ) END IF
There are times you are required to always round up to the next increment. For example, a filing may require you to round anything above 1000 to the next thousand. So 1001 would have to be rounded all the way up to 2000. To round to the nearest number instead, see Computation #0035 - Round to the Nearest Thousand.
The following examples assume that you are rounding up to the next 1000. To round to the next 10, 100, 10,000, etc., simply adjust the values in the computation.
In the first example, we first add 499 to the number variable NumberVar. This will produce a result that is always rounded up to the next 1000 if it is greater than an even thousand (1001 + 499 = 1500, which will round to 2000; 1000 + 499 = 1499, which will not round up). Next we divide by 1000, round with no decimal places, then re-multiply by 1000. This example will show the effect: 1001 + 499 = 1500; 1500 / 1000 = 1.5; 1.5 rounded to 0 decimal places = 2; 2 * 1000 = 2000. So 1001 rounded up to the next 1000 is 2000.
The alternative produces the same result through different logic. This computation looks to see whether the number is an even thousand. If it is not (i.e. if there is a remainder when it is divided by 1000) the next thousand is automatically returned.