DSXchange: DataStage and IBM Websphere Data Integration Forum
View next topic
View previous topic
Add To Favorites
Author Message
blewip
Participant



Joined: 10 Nov 2004
Posts: 77
Location: London
Points: 529

Post Posted: Thu May 05, 2005 9:32 am Reply with quote    Back to top    

DataStage® Release: 7x
Job Type: Parallel
OS: Unix
I am performing a type conversion from a Float to a String using the following

Code:

Trim(DecimalToString(DSLink2.NOMIN_QTY,"fix_zero,suppress_zero"))
 


This works fine apart from the fact that I have no control over the number of decimal places.

For example the output may look like 14256.43676

When I would want it to look like 14256.44

Is there a way to do this?
amsh76


since February 2006

Group memberships:
Premium Members

Joined: 10 Mar 2004
Posts: 118

Points: 671

Post Posted: Thu May 05, 2005 11:23 am Reply with quote    Back to top    

Why don't you round it to two decimal places first, and then do the conversion from float to string.
Rate this response:  
Not yet rated
blewip
Participant



Joined: 10 Nov 2004
Posts: 77
Location: London
Points: 529

Post Posted: Fri May 06, 2005 2:35 am Reply with quote    Back to top    

Thanks, yes that does kinda work. The Float is already defined as 15,2, however the scale may be meaningless for a Float. However if I convert the Float to a Decimal 15,2 and then do the DecimalToString in another Transformer this does indeed work (an extra transformer though).

I can also do the following
Code:
Trim(DecimalToString((Fabs ((DSLink2.NOMIN_QTY*100))/100),"fix_zero,suppress_zero"))


This rounds to two decimal places first as well and this works fine (in same transformer). It just seems a bit long winded.

I was hoping they'd be an easier way. The online manual gives the following arguments for the DecimalToString and I was hoping one of these might help, however I can't get any of them to work (except fix_zero). Also suprisingly the suppress_zero is not documented, is it documented anywhere else, how did anyone find this argument?

Code:
number (decimal)
[ fixzero(int8)]
[prefix (string)]
[prefixlen (int32)]
[suffix (string)]
[suffixlen (int32)](
Rate this response:  
Not yet rated
blewip
Participant



Joined: 10 Nov 2004
Posts: 77
Location: London
Points: 529

Post Posted: Fri May 20, 2005 2:16 am Reply with quote    Back to top    

I had a few problems with the old solution, and I found a better way. There appears to be a new function DFloatToStringNoExp, this converts to string. doesn't give you an exponential and allow you you have control over the number of decimal places.

Code:
DFloatToStringNoExp(DSLink2.FLOAT2DECI,6)


I sure people are using it, but it just doesn't appear in the documentation.

I also wanted to recipricol of a Float and found that it was better to convert to a String and then do the Maths.

Code:
1/DFloatToStringNoExp(DSLink2.FLOAT2DECI,6)


Seems slightly odd, but 1/100 was giving me 0.0099999999 before.
Rate this response:  
Not yet rated
Display posts from previous:       

Add To Favorites
View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



Powered by phpBB © 2001, 2002 phpBB Group
Theme & Graphics by Daz :: Portal by Smartor
All times are GMT - 6 Hours