Declaring unsigned doubles??

Jul 25, 2008 at 12:19pm
Hi, I was wondering if you can declare double integers as unsigned. I'm writing a program that can not accept negative prices and the prices declared are double. I then test the input with the following...If this isn't possibe what would be a way to test that only positive values were entered. Thanks for any help.

1
2
3
4
5
6
7
8
9
10
11
12
unsigned double single, half, full;

cin >> single >> half >> full;

if(!cin.eof() && cin.good()){
 call...member function
}
else
{
cout << "Invalid price entered"
}
Jul 25, 2008 at 1:44pm
No, you have to test for negative values yourself. Sorry.
Jul 25, 2008 at 4:02pm
1
2
if(single < 0 || half < 0 || full < 0)
cout << "Invalid price";
Topic archived. No new replies allowed.