Unitize
Unitize[x] gives 0 when x is zero, and 1 when x has any other numerical value.
Examples
Unitize a number:
Unitize[5]
(* 1 *)Unitize[0]
(* 0 *)Apply to a list:
Unitize[{-3, 0, 2, 0, 5}]
(* {1, 0, 1, 0, 1} *)Please visit the official Wolfram Language Reference for more details.