In one of my developments I came across calculating precision.
Precision is generally like a round-off function i.e. to decide at runtime to what value you want to round-off the number.
e.g. If I'm traveling in a hired car. For each kilometer it will cost me Rs. 10
The car owner will bill me on kilometer basis and if it is 9.37 km, he will bill me for 9.5 km. If I travel 0.75 km he will bill me for 1 km.
In this case the
Base precision value is - 1, means if I travel any distance less than a kilometer, it is going to cost me bill for 1 km.
Incremental precision is - 0.5, means round off the value to next incremental of 0.5 km
For 9.75, it would be 10. For 9.25, it would be 9.5 and so on.
To calculate this I have following code
totalKM = ((distTravelled - basePrecision) > 0 ?
(Math.ceil((distTravelled - basePrecision)
/ (incrPrecision)) * incrPrecision)
+ basePrecision : basePrecision);
Subscribe to:
Post Comments (Atom)
SpringBoot: Features: SpringApplication
Below are a few SpringBoot features corresponding to SpringApplication StartUp Logging · To add additional logging during startup...
-
There was a requirement in which user should be able to download an excel report from application, make some amendments and upload the exce...
-
I was facing 'java.rmi.NoSuchObjectException: Bean has been deleted' for the stateful bean instance. While reading about the error, ...
-
What Is a WebLogic Server Cluster? A WebLogic Server cluster consists of multiple WebLogic Server server instances running simultaneously an...
1 comment:
Good to see you back!!! Keep blogging.
Post a Comment