Each university does it differently. I know of one that just uses software to generate the result.
We don't. We discuss each student individually - average grades, 'trend', work rate and so on. To give an example, let's say the student averages 69%. You need 70% for a 1st class degree. As a Board we'll discuss the student and make a call - first or second. In cases like that we'll almost always give the student the 1st.
Lower down the scale can be different. Someone on, say, 49% average is looking at a 3rd class degree. The discussion might be (and we had this once) that the student didn't engage, didn't contribute in classes and so on and so he stayed at 3rd. No 2:2 for him.
This is why I always say on here - go to lectures. Talk to lecturers. Engage. Yes, you might skate by skipping the classes and just learning the textbook. But students that do that never do as well as the others.