3 ms·
If you are comparing values X and Y, just write 0 to address X and 1 to address Y. Then read address X. If X and Y are equal, then you would have written first
by Liquid_Fire 7y ago
If you are comparing values X and Y, just write 0 to address X and 1 to address Y. Then read address X.
If X and Y are equal, then you would have written first 0 and then 1 to the same address, so the final read would give you 1.
If X and Y are different, then you would read back the 0 you wrote to address X.
- nexuist 7y agoIt took me a bit to grok this but I think I finally understand it. Super clever. Now, how would you do greater than / less than comparisons?
- magicalhippo 7y agoThe native and super inefficient way would be basically the same: write 1 to all addresses greater or equal to X, and 0 to all addresses less than X, then read from address Y and see what you end up with. Probably a more clever trick out there though.