I was comparing two strings in C++ as follows:
if(s1 <= s2)
//do stuff
I had forgotten the intricacies of string comparison and quickly learned that in the following case:
s1 = "10.72";
s2 = "8.87";
The statement will evaluate to true and do whatever is inside the conditional. The comparison happens between the 8 and the 1. All ASCII representations of numbers are in increasing order from 48 (0) - 57 (9), and obviously 1 < 8.
I had thought that C++ took into account string length but that's incorrect. Would someone mind explaining why length is not taken into account from a C++ language design perspective?