Why don't I get the same result if I multiply all together in the first example?
The second gives the good result.
Code:#include <string> #include <iostream> using namespace std; int formatThousands(long long value) { string num = to_string(value); int insertPosition = num.length() - 3; while (insertPosition > 0) { num.insert(insertPosition, " "); insertPosition-=3; } cout << num << endl; return 0; } int main() { // 1. long long int chance = 0; chance += 49*48*47*46*45*44; cout << " Chance: "; formatThousands(chance); cout << "\n\n"; //2. chance=0; chance += (49*48*47*46*45); chance *= 44; cout << " Chance: "; formatThousands(chance); cout << "\n\n"; return 0; }