4 ms·
> The only function for which this is true is identity If you want to clamp a value to some arbitrary range (a hint to the name), then any function that does s
by geocar 11y ago
> The only function for which this is true is identity
If you want to clamp a value to some arbitrary range (a hint to the name), then any function that does so has this property.
unsigned char f(unsigned long x) { return x & 255; }
long f(long x) { return x < 0 ? x : -x; }
- lmm 11y agoThe return type isn't the same as the input type there. It only looks that way because of C's limitations. Put it this way: f(f(x)) never makes sense for those definitions of f; it would always indicate a programming error. And so the type system ought to prevent it.