3 ms·
The decision is so (apparently) obviously wrong that I'd really like to know what the decision process was. My first guess is that it involved some kind of arc
by User23 5y ago
The decision is so (apparently) obviously wrong that I'd really like to know what the decision process was.
My first guess is that it involved some kind of architectural peculiarity of the PDP11.
- bsder 5y ago1) Only "Two's Complement" signed arithmetic is asymmetric. One's Complement arithmetic wasn't uncommon on computers of the era and is fully symmetric. And, I believe that a PDP-7 uses one's complement. 2) "unsigned" didn't get implemented until about 5 years after C was initially implemented.
- kevin_thibedeau 5y agofabs() returns a signed result so abs() mirrors its behavior. Also if you're taking an absolute value, you're working in close proximity to negative numbers and risk accidentally performing subsequent operations on mixed types that cause an implicit cast from signed to unsigned. C's integer promotion rules allow this to happen.
- zarzavat 5y agoIf abs() returned unsigned then an expression such as -abs(x) would be surprising and wrong.