"<" is not noticing 0.10 as being less then 0

I'm trying to get this program to only except numbers that are less then 0, but as far as i can see the program thinks 0.5 is not less then 0

please tell me what I'm doing wrong

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
  #include <iostream>
using namespace std;
int main(){
	bool test = true;
	double decimal;
	cout << "choose a Number that is < 0" << endl;
	do{
		cin >> decimal;
		if(decimal < 0){
			cout << "***"<< endl;
			test = false;
		}
		else if(decimal >= 0.00){
			cout << ":" << decimal << ":" <<endl;
			true;
			cout << "You did not choose a number that is < then 0" << endl;
			cout << "Please try again" << endl;
		}
		else{
			cout << "error" <<endl;
		}
		
	}while(test);
	system("pause");
}
isaccthebro wrote:
but as far as i can see the program thinks 0.5 is not less then 0

The program is correct in that assertion.
so how is 0.5 not < 0, if you don't mind me asking?
0.5 = 1/2

Half is NOT less than 0.
Arslan is correct, .5 is less than 1, greater than 0.
If you have half an apple (0.5) and I have no apples (0) that means you have more apple than I have. In other words, you don't have less apple than I do.
Last edited on
Thanks, how did i not notice this (feeling real dump).
Thanks for not roasting my stupidness
Topic archived. No new replies allowed.