The generic version should probably copy the floating point logic, since it could be instantiated with a floating-point-like type (i.e. one with a "NaN")