3 ms·
In those situations, pick a random hex value, then convert and mod it. I can't tell what integer `0x4C mod 10` is off the top of my head. Turns out it's 6.
by function_seven 4y ago
In those situations, pick a random hex value, then convert and mod it.
I can't tell what integer `0x4C mod 10` is off the top of my head. Turns out it's 6.
- ouid 4y ago16 shares a divisor with ten, and thus has the same problem
- function_seven 4y agoSorry, not following you here. How does 16 and 10 sharing a divisor make the mod trick fail? As long as you pick a base that doesn't match the range you're picking within, you should be good to go. If someone asks me to "pick a random digit in [0x0, 0xF]", then I'll use base-10 as my start. 284. I have no idea which hex digit this will result in after I mod it by 16. It's 0xC, but I didn't know that going into it. Oh, wait. I think I do see what you're getting at. I would still know if it's even or odd, because 10 and 16 share 2 as a divisor, right?
- ouid 4y agocorrect