Total Armor and resistences...

How are these stats calculated? I'm trying to understand by switching gear.... But sometimes it really looks crazy.... Maybe are bugged...?