I really don't know the math.
The damage formula is much too long and complicated to post here, so look at this link: http://www.smogon.com/bw/articles/bw_complete_damage_formula