| Efficiency looks past current deficiency. We have the empty string: "\0" We have the null string: NULL There is no concept of an INVALID string, as float has NAN. This would be the result of trying to copy a string to a buffer that is too small. Or sprintf() into a small buffer. Or a raw string parsed as UTF-8 and is invalid. Correctness over efficiency. |
You've mentioned NaN propagation in another comment and I think that's a perfect example of the problem with this approach. Sorting a vector of arbitrary floats is a notoriously thorny problem because any float could be NaN, and as NaN is incomparable to any other float, there is no total ordering of floats. There is no general solution to this problem that doesn't involve making assumptions that could be faulty for some applications.