charizardcharz@lemmy.worldtoProgrammer Humor@programming.dev•How should I increment an int?
11·
3 days agoWhy not wait for a random bit flip to increment it?
int i = 0;
while (i != i + 1);
//i is now incremented
Why not wait for a random bit flip to increment it?
int i = 0;
while (i != i + 1);
//i is now incremented
I didn’t really dig too deep into it. It might be interesting to see what it actually compiles to.
From what I can remember result of i+1 would have to be stored before it can be compared thus it would be possible for i to experience a bit flip after the result of i+1 is stored.