News for hackers. Stuff that matters.
Re:Testing for Divisibility by 19 by qayxc on Monday November 23, 2020 @06:19AM (#25185603)
> 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.

Re:Testing for Divisibility by 19 by rjmunro on Monday November 23, 2020 @07:35AM (#25186081)
I 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.

Re:Testing for Divisibility by 19 by qayxc on Monday November 23, 2020 @06:57PM (#25193476)
> 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

Re:Testing for Divisibility by 19 by raverbashing on Monday November 23, 2020 @07:28AM (#25186027)
No 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)