Mistakenly passing a student I miscalculated the mark of one of my students and mistakenly notified him that he passed the class. However, I noticed my mistake after some hours and fixed it, thereby resulting in him failing the class. Obviously, the student is very upset now. Should I have left the mistake and pretend I hadn't noticed it?
On the few occasions where I've accidentally mis-reported a grade, mercifully the computational error was not great, and it was within my authority to change the pass-fail line (or other relevant line) by a small-but-sufficient amount to make my initial report "become correct". Of course, I correspondingly "improved" other peoples' grades to match. That is, if we are talking about a small adjustment, I feel that the initial grade announcement should be "made true" by changing the grade line.

My rationale for this is that precise gradelines are pretty meaningless, so a small change (in favor of students) is completely harmless, and thus avoids the very-bad fallout from recanting on a grade.

If some bizarre, large computational mistake occurs, so that one has reported an "A" instead of "F", it's probably not feasible to make the better grade "true". Whatever your local policies allow/require, do be sure to manifest the same "adjustment" (and only upward, by my thinking...) for every student in the course. Large errors, and/or large changes, should probably be discussed with other people in your department so that they'll  not be "surprised" at any further fallout.