Navigate Select ESC Close

THIS BLEW MY MIND

2025-07-14 Science & Technology
198.9k
5.2k
544
ThePrimeTime
ThePrimeTime
1.1m subscribers

Unlock all features

FREE: Get instant access to 10 AI summaries, chats, or transcripts per day.

Description

Twitch https://twitch.tv/ThePrimeagen Discord https://discord.gg/ThePrimeagen Become Backend Dev: https://boot.dev/prime (plus i make courses for them) This is also the best way to support me is to support yourself becoming a better backend engineer. ### LINKS -- https://florian.github.io//xor-trick/ Great News? Want me to research and create video????: https://www.reddit.com/r/ThePrimeagen Kinesis Advantage 360: https://bit.ly/Prime-Kinesis

Top Comments (10)

@killersquirel11 2025-07-14

"XOR has memory" has never made sense to my caveman brain. "XOR doesn't destroy information" makes more sense to me.

789 47 replies
@lucasa8710 2025-07-14

only prime could explain XOR swapping in the most cumbersome way possible LMAO, I relate to this guy so much, ADHD brain is a different universe

315 11 replies
@MakeKasprzak 2025-07-14

Nostalgic. I used to work on GameBoy games, which had a Z80-like 8-bit CPU that couldn't multiply or divide, and the SHIFT opcode couldn't shift by more than 1 position per opcode, so we relied on bit trickery to do everything. One such example, we could simulate multiplication/division by 16 using either 4x "SHIFT" opcodes, or the "SWAP" opcode (switches the top and bottom nibble in a byte) plus an "AND" opcode to zero out the upper or lower bits. The "SHIFT" and "SWAP" opcodes take 1 effective cycle (nb. not technically 1 cycle as all CPU operations on the Gameboy CPU take exactly 4 cycles, hence "effective cycle"), and the "AND" in this case takes 2 effective cycles (i.e. AND with an immediate value 0b11110000 or 0b00001111), meaning this only saved 1 effective cycle (not 2), but every cycle counts!

232 15 replies
@Impatient_Ape 2025-07-15

When Prime says "XOR has memory"... he's referring to the fact that XOR can be used as an invertible function so that no information is lost. If you think of XOR(a,b)=c as a sub-scripted or parameterized function XOR_a, then XOR_a(b) = c means that XOR_a(c) = b, so you can recover the original argument "b".

167 2 replies
@b.6603 2025-07-14

"This made me a firefighter" That's the automatic translation of the title to portuguese. I have no idea what it means. But XOR is cool and mysterious so I'm watching.

164 13 replies
@szymmarcinkowski 2025-07-14

Can you disable AI translations of titles somehow? For Polish language titles often contain errors and are being translated very poorly. Not sure whats the point of this anti-feature.

93 9 replies
@WhatsuppFudd 2025-07-14

Oh my Russell! Prime's face after some basic algebra means only one thing: he's a few videos away from getting into category theory. Haskell, here we come!! 😂

15
@HeinrichChristiansen 2025-08-09

XOR is kinda genius

4
@xanderlander8989 2025-07-14

Tide comes in, tide goes out. You can't explain that.

3
@MariusCristianCapatina 2025-07-18

Embedded software developers use some of these tricks everyday. Nice to see that there is appreciation for them by the big guys too.

2

Unlock the Data Inside
Turn Videos into Knowledge

  • Get FREE 10/day: transcripts, summaries, chats
  • Chat with videos, export text & PDF
  • $1 free API credit for RAG, chatbots & research

Free forever plan • All features unlocked

App screenshot