2 ms·
When you get access to a time machine, go back in time and have this argument with the poor grad student who committed this sin :) In assembler, comparisons ge
by ArkyBeagle 10y ago
When you get access to a time machine, go back in time and have this argument with the poor grad student who committed this sin :)
In assembler, comparisons generally have a result of zero when things are the same because hardware works that way. If the difference between two voltages is zero, they "null" and are the same.
In a pidgin, non-real assembler I'm making up:
MOV AX,A_VARIABLE
MOV BX,B_VARIABLE
CMP AX,BX ;; or maybe AND AX,BX or XOR AX,BX because flags
JNE THEY_ARE_NOT_EQUAL
JMP THEY_ARE_EQUAL
...
THEY_ARE_EQUAL:
...
THEY_ARE_NOT_EQUAL:
In 'C' if I am really concerned about this, I will:
const bool TheThingMatches = (strcmp(a,b)==0);
Edit: It ate my line breaks.