That is, for a particular definition of |a-b| that's what I want, roughly stated as "distance in the cyclic group" rather than integer |a-b|
Nice trick: for unsigned a,b,c, c<maxval/2, |a-b|<=c can be written as a-b+c<=2*c.
-
-
-
Stated more precisely, d(a,b)<=c, where d(a,b)=min(a-b,b-a), can be written as a-b+c<=2*c.
End of conversation
New conversation -
-
-
@RichFelker Yup. Classic unsigned range check. -
@stephentyrone Yes, but an interesting special case for 'distance between two values'. -
@stephentyrone My use case is making@musllibc's malloc safe against this uclinux abomination: https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/fs/binfmt_elf_fdpic.c?id=19d860a140beac48a1377f179e693abe86a9dac9#n390 …
End of conversation
New conversation -
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.