Page 1 of 1

Round to 2 decimal places For Double (53)

Posted: Wed Jan 02, 2008 11:57 am
by ds2000
i want to Round to 2 decimal places input and output is same i.e double (53)

Posted: Wed Jan 02, 2008 12:01 pm
by ArndW
Good on you, I am certain that you can do this in DataStage.

But if you want help in doing this, you need explain exactly what it is you are asking - what stage, converting from what type to what type?

Posted: Wed Jan 02, 2008 12:17 pm
by ds2000
I want to do this in Transformer in Px and source is Double (53) and Target is Double (53) in dataset which is then populated in db2 - Double (53).

Posted: Wed Jan 02, 2008 12:36 pm
by ArndW
You could round mathematically, i.e. INT(In.DBLCol*100)/100 or use an interim Decimal data type with 2 decimal places.

Posted: Wed Jan 02, 2008 1:09 pm
by dspxlearn

Code: Select all

sravanthi: Try OCONV(col,"MD2") 
I guess this is a parallel job and OCONV will not work unless Basic transformer is used. :wink:

Posted: Sat Jan 05, 2008 8:24 am
by ds2000
ArndW:
INT(In.DBLCol*100)/100 function is not available in px. and i tried to put decimal with 2 decimal places, it doesnt round.

Posted: Sat Jan 05, 2008 10:06 am
by ArndW
PX has 2 functions that do this : CEIL and FLOOR. Try

Code: Select all

FLOOR(In.DBLCol*100)/100
Note this will truncate, not round. For rounding you should first do a decimal conversion using rtype "round_inf"

Posted: Tue Jan 08, 2008 4:56 pm
by ds2000
ArndW:
I couldn't understand it. what is the syntax of round_inf ? please explain.

Posted: Wed Jan 09, 2008 3:23 am
by ArndW
I just did a bit of checking for correct syntax in the modify stage and noticed that there are actually 2 simple ways to do this. If your input column is called "Test" and has [10,4] defined then

NewTest1:Decimal[10,2]=Test
NewTest2:Decimal[10,2]=Decimal_From_Decimal [round_inf] (Test)

will both return rounded decimals to 2 places. This means that the implicit conversion will work just as well as explicitly using the "round_inf".

Posted: Wed Jan 09, 2008 1:35 pm
by ds2000
DFloatToDecimal(Link.DblCol, "round_inf") works fine in transformer when making stage variable to Decimal with 2 decimal places. Would it be able to handle a value for Double (53). What should be the decimal data type equivalent to Double (53) ?