added helper function 'SPSign'
avoiding divisions through zero