# Decimal to Char in PowerCenter

I did some tests with converting decimals to char in PowerCenter. The results were different than what i expected. I created a simple mapping with an Expression transformation. There are two inputs:

1. DEC_10_2, a decimal with 2 digits scale, Value 99.99
2. DEC_10, a decimal with 0 digits scale, Value 99

There are 10 outputs, all string(10). The result below comes from a verbose data session log (hence the TRUNCATED remark).

1. TO_CHAR(DEC_10_2): "99.99"
2. TO_CHAR(DEC_10): "99"
3. TO_CHAR(TO_INTEGER(DEC_10_2)): "100"
4. TO_CHAR(TO_INTEGER(DEC_10)): "99"
5. DEC_10_2: "99.9899999(TRUNCATED)"
6. DEC_10: "99.0000000(TRUNCATED)"
7. :UDF.PREP_BK1(DEC_10_2): "99.9899999(TRUNCATED)"
8. :UDF.PREP_BK1(DEC_10): "99.0000000(TRUNCATED)"
9. :UDF.PREP_BK1(TO_CHAR(DEC_10_2)): "99.99"
10. :UDF.PREP_BK1(TO_CHAR(DEC_10)): "99"

Note on 1 and 2: This is the conversion that i expect. The strings have the right scale.

Note on 3: The TO_INTEGER clearly rounds the number instead of truncing it.

Note on 5 and 6: I didn't use a conversion expression so this is an 'implicit' conversion. The conversion doesn't look at the scale. It tries to add as much digits as possible and because the string is only length 10, the number will be truncated. I would have expected 99.9900000 for number 5.

Note on 7 and 8: The user defined function is a null handling function and has a string as parameter. This triggers an implicit conversion so the results are the same as with 5 and 6.