=IF(ISTEXT(A4,1,IF(ISBLANK(A4),0,"A4 may have a number?"))
If, of course you don't want to distinguish between text and a number, the
formula could be changed, and similarly if you don't want to draw a
distinction between a blank cell and an empty text string.
Another possibility, depending on the answer to those questions, might be
=IF(A4="",0,1) or even =--(A4<>"")
I have assumed that you want B4 to contain a number 0 or 1, rather than text
strings "0" or "1".