Earlier quoted context omitted.
I like CoPilot's answer better than yours, and I think it's closer to what most people would do; clearly 0x3F is the wrong constant but the approach is good.
I like the manual solution better: it includes thought process without negative impact on readability or performance. This makes it easier to match the code against the specification, something a random (and in this case even wrong) magic number fails to do. But maybe I'm overthinking it.
You're correct.