01-07-2008 9:12 PM
Hi Friends,
I am trying to round a float value.
Suppose the value is 1.6666666666666666E-01
I need the output as 1.67
I hve been using ROUND function module but it gives me 1.6700000000E-01
when I use Packed decimal it takes as 0.17
Any suggestions..
Thanks
Chaithanya
01-07-2008 9:18 PM
01-07-2008 9:16 PM
You cannot get 1.67 from 1.6666666666666666E-01 because it is nothing but the value 1.6666666666666666 raised to the power of -1 which is 0.16666666666666 to whatever precision which when rounded will become 0.17 (just what you got using a packed decimal). There is nothing wrong in what you are getting.
01-07-2008 9:18 PM
01-07-2008 9:34 PM
Hi Rich,
Thanks Rich. Thanks for the solution. It got solved.
You are becoming richer by getting more points....
Just kidding.
Have a nice day.
Thanks,
chaithanya K
01-07-2008 9:43 PM
Not sure if this is the best way to do this, not sure that it will always work for all values, but in this particular case it does, hence the reason for my "?" in my above response.
BTW, the points make me richer, which means more food for the hungry.
/people/mark.finnern/blog/2007/11/28/food-for-points
Regards,
Rich Heilman
01-08-2008 6:20 PM
So you just multiply any value to get the your answer? How is that correct? I think you are doing the wrong thing to assume that you should multiply by 10. Are you working in one of those user exits where the "fixed point arithmetic" attribute is not checked?
01-09-2008 2:26 AM
Hi Srinivas,
Thanks for your reply. Now this thread has become a Knowledge Sharing.
As Rich already mentioned it is not the best solution but for me it worked out.
I am not working in any User exits. I had a floating point value when printed using forms it took large value.
1.6666666666
So I needed to truncate it or round it up to 3 decimals. Hope you understood.
Thanks,
Chaithanya K
Edited by: chaithanya k on Jan 9, 2008 7:57 AM