Jake
Jake

Reputation: 11

Windows batch - Why is this happening?

if 52524302617.60 lss 9660035072 (echo WRONG) else (echo Correct!)

Returns WRONG each time.

Upvotes: 1

Views: 84

Answers (2)

bw_üezi
bw_üezi

Reputation: 4574

It's a String compare and there is a max of character that are considered for compare.

as in the other answer by grawity it's only a numeric compare if both strings can be converted to integer and this assumes no decimal point and not more than 10 digits.

Upvotes: 0

grawity_u1686
grawity_u1686

Reputation: 16657

Arithmetics in the cmd shell are limited to integers, and if only performs numerical comparison if both sides consist entirely of digits.

Since 52524302617.60 has a . in it, a string comparison is performed using lstrcmp().

Upvotes: 1

Related Questions