String Comparison Using Inequalities in Excel

前端 未结 1 1512
醉梦人生
醉梦人生 2020-12-11 08:05

Can someone provide a reference to how excel compares strings using inequality operators in Excel? I have found some unexpected behavior:

In the below examples, the

相关标签:
1条回答
  • 2020-12-11 08:31

    What Excel does here is it compares the two strings character by character left to right until it finds a mismatch, and then the string with higher value character becomes the greater string. This is the standard method to compare strings -- it's used in pretty much all programming languages, databases and other software packages.

    So, for example, for the first line the comparison would go like this:

    Comparison  Benchmark   Outcome
        Q           Q        Equal
        1           4        Benchmark is greater - done comparing
     [space]     [space]     Ignored
        2           2        Ignored
        0           0        Ignored
        0           1        Ignored
        9           2        Ignored 
    

    For the fourth line it would be:

    Comparison  Benchmark   Outcome
        Q           Q        Equal
        4           4        Equal
     [space]     [space]     Equal
        2           2        Equal
        0           0        Equal
        0           1        Benchmark is greater - done comparing
        9           2        Ignored 
    

    And for the last line it would be:

    Comparison  Benchmark   Outcome
        Q           Q        Equal
        3           4        Benchmark is greater - done comparing
     [space]     [space]     Ignored
        2           2        Ignored
        0           0        Ignored
        1           1        Ignored
        4           2        Ignored 
    
    0 讨论(0)
提交回复
热议问题