I am not sure but looks like depending on the number of digits in cal value the final value is getting calculated, can someone let me know how to do this ?
That's not the way things work here. You tell us the logic you require and we will help you implement it.