简体   繁体   English

== 和 EQU 运算符之间的区别?

[英]Difference between == and EQU operator?

What is the difference between == and EQU operator in Batch? Batch 中==EQU运算符有什么区别?

Below is just a sample snippet:下面只是一个示例片段:

if !one! EQU - (
    if !one!==!two! (
        if !two!==!three! (
            goto endgame
        )
    )
)

If EQU finds that the two things being compared are valid integers (in octal, decimal, or hexadecimal), then an integer comparison will be performed.如果EQU发现被比较的两个东西是有效整数(八进制、十进制或十六进制),则将执行 integer 比较。

For example, if 0x64 EQU 100 (echo yes) else (echo no) returns yes because 64 in hexadecimal is equivalent to 100 in decimal.例如, if 0x64 EQU 100 (echo yes) else (echo no)返回yes ,因为十六进制的 64 相当于十进制的 100。

If either of the two things being compared cannot possibly be a valid integer (the number 09 , for example, which would be octal except that 9 isn't a valid octal digit), then a string comparison is performed.如果要比较的两件事中的任何一个都不可能是有效的 integer (例如,数字09 ,除了9不是有效的八进制数字外,它将是八进制),则执行字符串比较。

== only runs a string comparison, so if 0x64==100 (echo yes) else (echo no) returns no because the two strings are different. ==仅运行字符串比较,因此if 0x64==100 (echo yes) else (echo no)返回no ,因为两个字符串不同。

In terms of simple string comparisons, the two operators act in essentially the same way, but EQU takes a few clock cycles longer because it first has to try to convert the two items to integers.就简单的字符串比较而言,这两个运算符的行为方式基本相同,但EQU需要更长的几个时钟周期,因为它首先必须尝试将这两项转换为整数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM