Page 1 of 1

Rounding and decimals

Posted: Thu Mar 17, 2005 8:24 am
by peterbaun
Hi -

Is the following expected -

Job :
src --> xfm --> db2

In the xfm 2 decimal numbers are divided in a stage variable and the result put in a target field defined as a decimal(15,4) which then is inserted into the db2/as400 database where the field also is defined as decimal(15,4).

In version 5.2 there is no problem with this, the job runs without errors/warnings -
Eg.
var1 = 23.3150
var2 = 30.0000
In the stagevariable : var1 / var 2
Then the result inserted into the db2 database is 0.7772

In 7.5.1 I get a warning :
SaOrLiStockDayTest..xfm: The column data has been truncated to '0.77716666666666'.

The data is inserted into the database as 0.7772 but it is not good since we get a lot of warnings (hence the job aborts!).

I am aware that in the transformer the value internally is represented as 0.777166666666667 but the question is, is this expected behaviour in version 7.5.1 - compared with 5.2 ?

It is easily solved by using the function NumericRound4(), but I would like to avoid this solution since it then has to be implemented a lot of places.

Thx

/Peter

Posted: Thu Mar 17, 2005 8:55 am
by Sainath.Srinivasan
I have seen it when we cross the barrier from DS 5 to 6. V 5.x does not bother much about the datatype but V 6.x expects the data to comply with the metadata more strictly.

Re: Rounding and decimals

Posted: Fri Mar 18, 2005 11:31 am
by jseclen
Hi Peter

Use the next data stage function

Formato = "R": Num_Decimals
Ans = FMT(Number, Formato)

In your case set the next values

Formato = 'R4'
Ans = FMT(0.77716666666667,'R4')

The result is 0.7772

I hope this help