Glad to help and thanks for the rep!

On second look it really should be

=IF(SIGN(D6)=1,1,0) - SIGN(D6)*P