RPGIV @ Work

A unique site for RPG and System i Lovers


Hi, this site will provide all what you need in System i and RPG developments.

My Name is Chamara Withanachchi, System i Expert and RPG Developer. And in the field for last 11 years.

I hope you will find lot of valuable information from this site

Using %DEC Print E-mail
User Rating: / 0
Written by Chamara Withanachchi   
Using %DEC

Credit goes to the Original Author

The %DEC function converts a character value to a packed decimal value, but decimal does not align itself the same way that the Move operation did. The decimal point in the character field is optional, but if it's not there, %DEC will assume you are converting to a whole numeric value, without decimals. In your example, %DEC is trying to convert 0250, not 0.250; ergo, the "too small to hold result" error.

If you want to align the decimals with the attributes of the result, the generic formula is:

	NumResult = %Dec(CharSource:%Size(CharSource):0) /(10**%Decpos(NumResult));
<Previous   Next>