String Compare “Logic”

前端 未结 11 1612
悲哀的现实
悲哀的现实 2020-12-06 19:06

Can anybody please tell me why the string comparisons below deliver these results?

>>\"1040\"<=\"12000\"  
True  
>> \"1040\"<=\"1         


        
11条回答
  •  眼角桃花
    2020-12-06 19:43

    how about making them the same length?

    That would unify numbers and alphas

    1040 becomes 01040

    01040 < 12000 now it makes sense

    maybe that is why he felt it was wrong to compare strings of different length when the strings are numbers they should be the same length

提交回复
热议问题