Need help with a formula to correctly subtract decimals with a base of 3 not 10

Gusnk

New Member
Joined
Oct 21, 2009
Messages
48
Office Version
  1. 365
Platform
  1. Windows
Experts -

I handle baseball stats (using excel) for a local league I'm associated with. My problem is when subtracting (to get the correct innings pitched) sometimes the result is incorrect. The formula I am using is the follwoing one INT((INT(R275)-INT(S275)+(MOD(R275,1)-MOD(S275,1))/0.3))+MOD((MOD(R275,1)-MOD(S275,1))/0.3,1)*3/10. Anytime that the decimals (see example 1) are the same the result should be zero, but instead the decimal is a 3. It does not happen when the deciamls are different (with the exception the decimal of 0) (see examples 2) and the result is correct.

Example 1: incorrect results
71.2 - 51.2 = 20.0 this should be the correct result but instead it provides the result as 20.3.

Example 2: correct results
90.0 - 71.1 = 18.2
58.0 - 4.0 = 54.0

Any and all help would be greatly appreciated.

Merry Christmas and Happy New Year to all

Best regards,
Gus
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
Baseball is very eccentric in its notation for innings pitched and it's a pain to do arithmetic on it. I would do this with two Lambda functions that convert from decimal innings to number of outs, and from number of outs to decimal innings. Then convert to outs, do the arithmetic, and convert back to innings. This makes your cell formulas much easier to write and understand.

Innings:
=LAMBDA(Outs,INT(Outs/3)+MOD(Outs,3)/10)

Outs:
=LAMBDA(Innings,INT(Innings)*3+MOD(Innings,1)*10)

$scratch.xlsm
ABCD
1SumDiff
220.011.031.09.0
320.111.031.19.1
420.211.031.29.2
520.011.131.18.2
620.111.131.29.0
720.211.132.09.1
820.011.231.28.1
920.111.232.08.2
1020.211.232.19.0
Innings
Cell Formulas
RangeFormula
C2:C10C2=Innings(Outs(A2)+Outs(B2))
D2:D10D2=Innings(Outs(A2)-Outs(B2))
B8:B10B8=B5+0.1
 
Upvote 0
Tetra201 & 6StringJazzer -

I want to thank you both of you with helping me find a solution.

Best regards,

Gus
 
Upvote 0

Forum statistics

Threads
1,223,910
Messages
6,175,320
Members
452,635
Latest member
laura12345

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top