Search code examples
androidalgorithmarithmetic-expressions

How to system know that one over of cricket has 6 balls (Calculation) in Android


I'm developing a cricket app and I'm getting problems when I'm working with overs. We all know that whatever calculation is done in calculator is done with 10.

For example :

If there are total overs : 20, and current over 2.1 And I want to calculate remaining overs.

So the formula would be : (total overs - current overs)

The answer should be 17.5

But I'm getting the answer as 17.9

Same thing occurrs in run rate and required run rate.

What I'm actually doing wrong?? Anyone has some algorithm or formula or any code that can convert convert overs like this.

Thanks.


Solution

  • float total=total-0.4;
    float current;
    float remaining=total-current;