when im rounding it or finding the abs … it is giving like 8.35. trunc is truncating all the decimals.

i would like to get 8.34, i dont want to round off … i want to truncate the remaining decimal. I meant i wanted to get the result as 8.34 and i dont want 0.00512

For Example in some record CreditAmt is 500. Here, as per my requirment i’m splitting this value in to 3, based on rate values. and inserting 3 records(with split value- debit value) in to another table. so at last when i’m checking the total of credit and debit amount, i’m getting some difference in points like 500.02 like that. I would like to avoid these. I believe this is happening because of rounding the value in to 2 digits. so instead of rounding i want to truncate the remaining digits.

You’re not getting to the root cause of this issue, which has to do with the precision of your numbers. Cutting off decimals only appears to make the error go away in that particular example, it doesn’t really anything. Do the math with a credit limit of 100. You’d end up with three records of 33.33, which adds up to 99.99. If you cut off those decimals, you end up with a total of 99.

All that you’re doing is rounding intermediate amounts to too little precision, which causes rounding errors when you add them back together again. In your case, with a credit limit of 500 divided into three records, with a precision of 2 decimals, you get three records with 166.67, which add up to 500.01. If you would round to 3 decimals, you get 166.667, and those would add up to 500.001, which rounds perfectly to the original amount, and all you’d have to do is define the precision in the display controls. Personally I would even consider using a precision of 5 decimals.

Kranthi, this is one example of when precision makes a difference, and it is definitely not just for display purposes.

I can’t say anything about the code there, but I disagree that this should be fixed by code. With a proper design, there should not be a need for any code. This is a design issue, and if they would just think about setting the proper precision, the values would add up perfectly.