1) Don't create variables with _ as the first character. That's used for internal values
2) top, bottom, whole are probably integers.
WaltP
Posting Sage w/ dash of thyme
10,506 posts since May 2006
Reputation Points: 3,348
Solved Threads: 944
The issue is integer division vs. floating-point division.
Integer division divides an integer divisor into an integer dividend and produces an integer quotient. For example, if you have 11/3, integer division will produce a truncated integer result of 3 instead of the actual correct value of 3.6667, which is a floating-point value.
In your code, you have this:
3/4 /**100+(_whole*100)*/ << endl;
notice how the 3 and the 4 do not have decimal points. This causes C++ to interpret them as integers, which results inint / int. This combination results in integer division.
Can you think of a way to change this code so that it results in double / double which will give you floating-point division instead?
Fbody
Posting Maven
2,930 posts since Oct 2009
Reputation Points: 833
Solved Threads: 393