Skip to main content
13 events
when toggle format what by license comment
Jun 23, 2021 at 9:12 comment added htmlcoderexe Huh, another great reason to keep chunk sizes at power of two sizes...
Jun 19, 2021 at 17:36 vote accept Nick
Jun 19, 2021 at 17:36 answer added Nick timeline score: 2
Jun 16, 2021 at 17:56 comment added Stephane Hockenhull @Nick the way two's complements work you can mask off powers-of-two numbers minus one and they wrap-around eg: (X & 3) in binary is (X & 0011b) : 0000b, 0001b, 0010b, 0011b, 0000b, ... So you get a count that wraps. Only works for power-of-two modulos (2-1, 4-1, 8-1, 16-1, 32-1, ...) and for negative numbers only in two's complements form (this trick doesn't work with one's complements systems, modern systems don't use one's complements for integers so no worries, we're fine there). This is getting past the scope of this question but look up one's complement vs two's complement for more detail
Jun 16, 2021 at 14:22 history edited Nick CC BY-SA 4.0
deleted 189 characters in body
Jun 16, 2021 at 14:13 history edited Nick CC BY-SA 4.0
deleted 83 characters in body
Jun 16, 2021 at 14:13 comment added Nick @DMGregory This solved the issue! But I don't understand why!
Jun 16, 2021 at 12:21 history edited Nick CC BY-SA 4.0
added 49 characters in body
Jun 16, 2021 at 11:54 comment added DMGregory Did you try using a bitwise AND operator & 15 instead of modulo % 16?
Jun 16, 2021 at 9:00 history tweeted twitter.com/StackGameDev/status/1405087773225361408
Jun 16, 2021 at 8:36 answer added htmlcoderexe timeline score: 3
Jun 16, 2021 at 6:48 history edited Nick CC BY-SA 4.0
edited body
Jun 16, 2021 at 6:32 history asked Nick CC BY-SA 4.0