![]() |
|
#1
|
|||
|
|||
a question about / operatorHey guys, I'm learning C++. I've written my own first programs and I noticed this.
how come : statement: C=a/b; if a/b<1 the program will say C=0. Even when I defined C as float. Should you define C as another type, or can't c++ calculate with numbers -1 > 0 < 1 ? thnx |
|||
|
#2
|
|||
|
|||
|
If C is defined as a float, it should have a few decimal points.
Floats won't throw away that much info. For curiosity, try making C a double. How do you print out the answer? If you're using printf, and it's outputting an integer %d, it probably is rounding it for you. Garth Farley |
|
#3
|
|||
|
|||
|
here's a part:
CPP / C++ / C Code:
I will try making some floats double's. thnx |
Recent GIDBlog
Problems with the Navy (Officers) by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| a C input question.. | tmike | C Programming Language | 2 | 19-Sep-2003 02:39 |
| a C input question | tmike | C Programming Language | 1 | 16-Sep-2003 02:31 |
| char to operator | calculus87 | C++ Forum | 3 | 04-Sep-2003 10:05 |
| a noobish compiler question | Charunks | C++ Forum | 5 | 03-Sep-2003 02:18 |
| Operator overloading (not happening) | gmn | C++ Forum | 11 | 30-Aug-2003 08:18 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The