Truncate and Round Float type data

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
suresh.narasimha
Premium Member
Premium Member
Posts: 81
Joined: Mon Nov 21, 2005 4:17 am
Location: Sydney, Australia
Contact:

Truncate and Round Float type data

Post by suresh.narasimha »

Hi

I have a Sybase source with Column A as Float. I want to Truncate the value of decimals to 8 places and round it and if there is a zero after decimal place, that should be padded with 8 zeroes.

My job design is

Sybase Src (Float) ---> Transfrmer ----> Sequential file (Float)

I didn't find a function to do this in Transformer.

Please suggest how can I do this.

Thanks
Suresh
SURESH NARASIMHA
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Can you post some input and output examples, please?
-craig

"You can never have too many knives" -- Logan Nine Fingers
suresh.narasimha
Premium Member
Premium Member
Posts: 81
Joined: Mon Nov 21, 2005 4:17 am
Location: Sydney, Australia
Contact:

Float data type trunc and round

Post by suresh.narasimha »

Hi Chulett

Here is some sample data input and desirable output

Code: Select all

Input                               Output  (8 decimals)
=====                           ==========
0                               0.00000000  - Padded with zeroes 
1.22334222765                   1.22334223  - Truncate and Round
1.23244                         1.23244000  - Truncate and Round 


Thanks
SURESH NARASIMHA
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Thanks for that. Added some

Code: Select all

 tags so the example was readable.

Just want to point out that your target field will need to be a [i]string,[/i] not another float, if you want to control the formatting like that.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply