Page 1 of 1

ABS() function

Posted: Wed Jun 08, 2005 9:25 am
by kiran reddy
Hi,

I have a strange experience working with the abs() function.
We have a reqirement that should take the absolute value of an integer and then rounded to two decimals. When ever we are geting some -ve numbers these are converted to +ve numbers using the abs() function, but it is loosing the precision. like for example
abs(31.33) gives 31.33 as output.
abs(-31.333) is giving 31 as output. Then we took a work around to accomplish this, by multiplying numbers less than zero with -1 and then rounding. Does any one know why is it so ?


Thanks.

Posted: Wed Jun 08, 2005 9:51 am
by elavenil
Can you check the following the environment variables for the project.

1. APT_DECIMAL_INTERM_PRECISION
2. APT_DECIMAL_INTERM_SCALE
3. APT_DECIMAL_INTERM_ROUND_MODE

Hope this would give a clue to understand why the number is rounded to the whole number.

Regards
Saravanan

Posted: Wed Jun 08, 2005 10:19 am
by dsdesigner
Hi Kiran,
The DataStage documentation specifies that the input argument to the abs function should be of type int32 and return type is a dfloat . But in that case even your +ve number have to be truncated. I tried it with an example and have noticed that the decimal part of my positive numbers are truncated. Are you sure that in your case for +ve numbers the fraction part was not truncated?

Thanks

Posted: Wed Jun 08, 2005 12:53 pm
by kiran reddy
In fact I didn't find any such environment variables in our project. May be something we need to set it up now ! Thanks for your response.

Also we were getting all -ve numbers from source, so I guess we didn't actually take a +ve number and check, but somehow we got into this mis-conception, Thanks for bringing this up.

Posted: Thu Jun 09, 2005 9:32 pm
by benny.lbs
Saravanan,

I also can not find the environment variables in DS Administrator. They are the User defined variables ?

How can you find the information about the APT variables, what 's the possible value ? any doc can be refered ?

Posted: Fri Jun 10, 2005 12:23 am
by ray.wurlod
There's an appendix in the Advanced Developer's Guide, which ships as part of the standard manual set.

Posted: Fri Jun 10, 2005 2:07 am
by benny.lbs
Ray,

For "APT_DECIMAL_INTERM_ROUND_MODE", the book said "Specifies the default rounding mode for any decimal intermediate variables required in calculations. The default is round_inf. "

The default is round_inf, but how can I know other possible value ?

Regards,
Benny.lbs

Posted: Fri Jun 10, 2005 4:00 am
by elavenil
These variables can be found in the Environment varibales section in Advanced PX developer's guide.

Possible values are depends on your requirement, which is how many precision and scale that you need in your requirement.

Regards
Saravanan

Posted: Fri Jun 10, 2005 8:37 am
by benny.lbs
I just want to know the possible value of APT_DECIMAL_INTERM_ROUND_MODE, not precision or scale. Since the default value is round_inf, it is hard for me to guess other possible value.

Would anyone can help ? Thanks a lot.

Posted: Fri Jun 10, 2005 8:44 am
by Simona
Hi dsdesigner,
Since ABS will for sure truncate the decimal, do you know any other alternative(Function?) to do the ABS without truncation except the workaround posted by Kiran??
Thanks!

Posted: Fri Jun 10, 2005 11:35 am
by dsdesigner
FABS(). I just stumbled upon this funtion that takes a float as input and calculates the absolute values of the number. I tried with an example and it works good for me.

Maybe Kiran can try this.

Thanks,
Shekar

Posted: Fri Jun 10, 2005 12:06 pm
by Simona
Shekar,
Where do I find FABS(), I check the documentation and cannot even find the FABS() in derivaiton editor! Do I have to customize the pallette or do something else to get this?

Thanks for your help!

Posted: Fri Jun 10, 2005 12:38 pm
by dsdesigner
FYI I am using 7.1 version of Datastage
Thanks,
Shekar

Posted: Fri Jun 10, 2005 3:40 pm
by Simona
I found it! Thank you so much! I just look into Basic Transformer a while ago, that's why!

Posted: Wed Jan 30, 2013 5:15 pm
by cdp
Fabs !! Thanks for that dsdesigner, had exactly the same issue, and Fabs worked perfectly !