Second, in that case, I believe Koeiegeloei's formula is indeed more reliable, when corrected. Assuming A1 and A2 are already rounded to the required precision, use:
IF(ROUND(MOD(A1,A2),2) = A2, 0, ROUND(MOD(A1,A2),2))
This is needed because even though MOD(A1,A2) - A2 < 0 is always true [1], ROUND(MOD(A1,A2),2) = A2 might become true due to rounding.
Hi, thanks for the valuable comments! Sorry, that I am not a quick responder, but I still got something to share on this topic.
I understand that joeu2004's formula is better in many cases. However, in my special case it does not always give the results I desire. I will show this again with a simplified example. Below the results with the formula I proposed (and which gives wrong results
in many other cases).
| Formula |
Result |
| 0 |
0 |
| =IF(MOD(A2+1/3,1)=1,0,MOD(A2+1/3,1)) |
0.333333333 |
| =IF(MOD(A3+1/3,1)=1,0,MOD(A3+1/3,1)) |
0.666666667 |
| =IF(MOD(A4+1/3,1)=1,0,MOD(A4+1/3,1)) |
0 |
Using joeu2004's modification the result is:
| Formula |
Result |
| 0 |
0 |
| =IF(ROUND(MOD(A1+1/3,1),12)=1,0,ROUND(MOD(A1+1/3,1),12)) |
0.333333 |
| =IF(ROUND(MOD(A2+1/3,1),12)=1,0,ROUND(MOD(A2+1/3,1),12)) |
0.666667 |
| =IF(ROUND(MOD(A3+1/3,1),12)=1,0,ROUND(MOD(A3+1/3,1),12)) |
1 |
Of course I understand, that 1 can mean either 1 or 0.99999 (or whatever). In my calculations it is important to see when I enter a new phase, which is the case when Result = 0. So I want to discern between numbers that are exactly 1, or just a bit smaller
than 1. Therefore I am looking for a formula that will give a zero in case a zero should be the true mathematical answer. This would be easy when it always happens in the same cell, but unfortunately I have a matrix which is filled with a more complex equation
in the way that is presented in the tables above.
So my point is that I don't want to see a 1 or a 0.999999 or similar, when it should mathematically be a zero. I am now starting to understand that this is a very ambitious goal!
Nevertheless, I have the impression that my (actual) equation will never have the form of 1000.4-1000. So in this case my proposed formula seems to suit my needs best.
Please let me know if you are sure that I shouldn't use my proposed formula. I am not a mathematician, so please give an example in that case! Thanks in advance!