It's calculatet in three steps:
1. attack strentgh = base damage
attack var = variation up and down off damage
E.g. AS=100 and AV=20 will make a damage of 80 to 120 (this is what you see when you hover over the attack command of your unit ingame).
2. Attack-type / Armor multipliers (defined in the techtree, not the faction!, XML, e.g. magitech.xml):
Say the above gave you, in a particular strike, 94 Damage.
Say the multiplier for the attack type (say piercing) and the target unit's armor (say organic) is 1.25, you get 94 x 1.25 = 117.5, say 118 (don't know if / how roundups are made).
3. Say the attacked unit's armor value = 30:
118-30 = 88 This is how much HP the target will loose.
P.s.: Apparently, if the resulting value is less than 1, the target will loose 1 HP. See silnarm's post (reply #6 in this thread).
EDIT: Edited for clarity sake.
EDIT 2: Update following silnarm's clarification on minimum 1 HP loss on the unit attacked.