If the variable's value was that flakey (basically random), I would probably use a string comparison rather than an arithmetic comparison though, as the arithmetic comparison would error out if the string was something like "12abc".
@Kusalananda yes, apparently, but why and where is that documented? @JeffSchaller found a good reference (the bash manual) that explains why a variable that evaluates to an empty string is treated as 0, or at least a reference mentioning that it happens, if not why.
:64475568... aand a reason to switch to doing string comparisons for simple equality comparisons, possibly. At least if you don't have control over the data.