When neither of the above conditions are met, then the parent entitled to the dependency exemption is that parent with whom the child resided for the longest period of time during the taxable year.  Or if the child resides with both parents for the same amont of time during such taxable year, the parent with the highest gross income.  IRC Sec. 152(c)(4)(B)(1) and (2).