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.
Aucun commentaire:
Enregistrer un commentaire