News for hackers. Stuff that matters.
Re:Undefined behavior can result in time travel by hornetblack on Friday June 27, 2014 @10:51PM (#7957279)
In some programs I like to have something like this to catch potential bugs:

    int abs_s(int x) {
        assert(x != INT_MIN);
        return (x >= 0) ? x : -x;
    }
Re:Undefined behavior can result in time travel by ygra on Saturday June 28, 2014 @03:59AM (#7957733)
This assumes two's complement, though. With one's complement even `INT_MIN` would be fine to negate ;)

(On that note: Are there even machines left to write code for that don't use two's complement? Or 8 bits per byte?)

Re:Undefined behavior can result in time travel by nitrogen on Saturday June 28, 2014 @10:56AM (#7958339)
It has been mentioned on HN before that there are DSPs that use the same size for byte, short, and int, and that size is not 8 bits.