All comparisons are performed using native binary because that is the internal representation, unless you need to compare the textual representation of a binary number.
For a platform specific answer, check the assembly language for your platform's processor. Many modern processors have assembly language instructions for comparing regions of memory.
As other commenters have stated, memcmp
is your best choice because it should be optimized for your platform.
If you must write your own, I suggest loading a word from memory and comparing memory word by word until there is not a match. If you need more details, compare the words byte by byte to find where the exact difference is.