Answer the question
In order to leave comments, you need to log in
Is it correct to compare numbers declared as strings, i.e. with a string object?
Can there be any problems (data loss, rounding, etc.) with such a comparison.
How does the compiler behave in the situation below?
int main() {
string num_in_str = "100.05";
string num_in_str2 = "100.03";
if (num_in_str < num_in_str2) {
// ...
}
return 0;
}
Answer the question
In order to leave comments, you need to log in
How does the compiler behave in the situation below?
string::operator <
. If it is a std::string, then the operator performs a lexicographic comparison, i.e. compares the characters of both strings in turn up to the first different pair, the smaller one will be the string to which the character with the lower code belongs. Can there be any problems
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question