on 10-07-2016 9:06 AM
Hi Experts,
We are facing an issue with rounding the values, please help.
Example:
Incoming values | Rounding |
90.9091 | 90.9 |
90.9091 | 90.9 |
90.9091 | 90.9 |
90.9091 | 90.9 |
90.9091 | 90.9 |
90.9091 | 90.9 |
90.9091 | 90.9 |
90.9091 | 90.9 |
90.9091 | 90.9 |
90.9091 | 90.9 |
90.909 | 90.9 |
1000 | 999.9 |
After Rounding Sum is not matching....!
In some scenarios if we round for 2 decimals it works and in some it will work with 3 decimals.
Please help me in achieving this in a generic way.
Thanks in advance..!
Regards,
Sateesh.
HI Sateesh,
If you are rounding value for 2 or 3 decimal the accuracy will be quite close to total.
after rounding the value it will vary by .1 or .01 or .001 something like depending upon decimal value.
For accurate sum value round the value till 4 digit as per you example.
Use FormatNum funtion for the same.
Regards,
Gaurav
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Sateesh!
You should keep in mind that there will always be the cases when your rounded sum differs from original sum.
One of approaches is to check both of your sums and in case of difference split the difference to minimal values and add it one by one to your rounded values.
3.3334+3.3334+3.3332=10
3.333+3.333+3.333=9.999
3.333(+0.001)+3.333+3.333=10
Regards, Evgeniy.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.