5 ms·
Not really, first of all because the tricks are in base 10 But you can make tricks for base 16 or 256 if you really need to check for a certain divisibility mu
by raverbashing 6y ago
Not really, first of all because the tricks are in base 10
But you can make tricks for base 16 or 256 if you really need to check for a certain divisibility multiple times
- qayxc 6y ago> But you can make tricks for base 16 or 256 if you really need to check for a certain divisibility multiple times You don't need any tricks in that case since a simple bit mask (bit-wise AND) will do the trick then.
- raverbashing 6y agoNo bitmask will give you divisibility by 3 in base 16 In this case (division by 3 in mod 16) is the same as base 10: if the sum of digits is divisible by 3 then it is divisible (and the "extra digits" are 'c' and 'f') Examples: 0x3c (60) -> sum = 0xf (divisible) 0x2d (45) -> sum = 0xf (divisible)
- rjmunro 6y agoI may be misunderstanding - a bit mask only tells you if something is divisible by 16 or 256 (or any other power of 2) I think he's saying in base 16 you can make a trick to check divisibility by e.g. 15 in the same way you can check divisibility by 9 in base 10. So is 0xE1 (225) divisible by 0xF (15)? 0xE + 0x1 = 0xF, so yes.
- qayxc 6y ago> I think he's saying in base 16 you can make a trick to check divisibility by e.g. 15 in the same way you can check divisibility by 9 in base 10. Yeah - I misunderstood there and thought they meant divisibility by 16 or 256 not in base 16 or 256. Should've had my morning coffee first :D