They just calculate it as if they were two different classes. Therefore, at the end it's an average.
So, if your bio class was 4 credits and you got a D and an A. It's like you took 8 credits and got a (D(1)+A(4))/2= 2.5= C+
I retook a few classes and my university just substituted the old grade with new when calculating my GPA, unfortunately AADSAS didn't do the same so my AADSAS gpa was significantly lower than what I thought I had.. oh, well, wish I knew about this before I retook all those classes...