fix inconsistency between cast and math boolean ops