4 ms·
You're right that this test would be UB for signed integers. See here for that in action, as well as one way to test it that does work: https://godbolt.org/z/s
by steveklabnik 2y ago
You're right that this test would be UB for signed integers.
See here for that in action, as well as one way to test it that does work: https://godbolt.org/z/sca6hxer4 https://godbolt.org/z/sca6hxer4
If you're on C23, uercker's advice to use these standardized functions is the best, of course.