1.) Half-adjust using

**Eval**. This example converts US pounds to kilos:

/free

kilos=0;

if pounds > 0;

eval(h) kilos = pounds/2.204623;

endif;

/end-free

2.) Half-adjust using

**%dech**, note that this method requires length and number of decimals parameters and will not allow %len or %decpos as parms:

/free

kilos=0;

if pounds > 0;

kilos = %dech(pounds/2.204623: 11: 4);

endif;

/end-free

According to IBM, half adjust adds 5 to the last or right-most decimal position +1. For example, if your result has four decimal positions half adjust will add 5 to the fifth decimal position which may or may not affect the fourth decimal position.

Half adjusting does have an effect in our example assuming the result field "kilos" has four decimal positions but the divisor in our calculation has six decimal positions and the result could have even more.

Without half-adjusting, to convert fourteen US pounds to kilos:

kilos = 14/2.204623 = 6.35029209075656011919...(well, you get the point)

With half-adjusting:

kilos = 6.3503

Other options are to use %UNSH (convert to unsigned format half-adjusting when only positive numbers are expected) and %INTH (convert to integer which basically just truncates any decimal places).

With %INTH:

kilos = 6.0000