Problem with reading into a double

Hello, writing a program I found a small error in reading double. Why if I don't write a double value using dot notation (2.5) but using the comma (2,5) numbers after the decimal point are truncated?
for example :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
int main()
{

	double val1 = 0; 
	double val2 = 0; 
	
	cout << "Please enter two floating point value : "; 
	cin >> val1 >> val2; 

	if (val1 > val2)
		cout << val1 << " is bigger than " << val2 << "\n\n"; 

	if (val1 < val2)
		cout << val2 << " is bigger than " << val1 << "\n\n"; 

	return 0;

}


If I enter the value 2,3 2,4 the get truncated ? why the output is : 2 is bigger than 0 ? why the computer didn't read the second number into val2 ?
I'm just a beginner
When you enter 2,3, are you saying val1 = 2 and val2 = 3?
If yes, then what's happening is the program is actually doing this:

val1 = 2 and val2 = ,


Somebody correct me if I'm wrong
Last edited on
If I understand what you're trying to do, use a . as the decimal point, e.g. 2.3 2.4

Please enter two floating point value : 2.3 2.4 
2.4 is bigger than 2.3 
Last edited on
Topic archived. No new replies allowed.