I have looked but cannot find a specification of precisely when a batch file IF comparison using a numeric compare-op (eg gtr) is done numerically instead of treating its arguments as strings.
I found this question Windows batch file IF failure - How can 30000000000000 equal 40000000000? but its explanation -- If you have any non digit characters, then IF does a string comparison -- isn't complete. For example:
@echo off& setlocal enabledelayedexpansion
if "123" gtr "99" echo greater
if 099 gtr 10 echo greater
if "+1000" gtr "0x99" echo greater
if 12-1 gtr 3 echo greater
if +1000 gtr 0x99 echo greater
Only the last IF above is done numerically and echoes greater... yet neither side of its compare-op is comprised entirely of digits.
If both arguments can be converted to a numeric, then the comparison is performed numerically, unless either side is quoted.
Hence, since +1000 and 0x99 are both numeric according to the parsing rules (see set /?
then the comparison is performed numerically (a string starting 0x
is interpreted as a hex and otherwise if it starts 0
, then octal)