Re: trouble using fractions
Raw integers (numbers without a decimal point) are considered ints- they are only whole numbers (0, 1, 76, -45), so you lose anything after the decimal point.
Try to do it the other way: what happens when you divide a big number by a small number? Try 12/5, for example.
One solution would be to use them as raw doubles (numbers with a decimal point). Try 1.0/12.0. You could also cast one (or both) of them:
double a = ((double)1)/12
When you mix a double and an int, the answer is considered a double.
Re: trouble using fractions
Quote:
Originally Posted by
KevinWorkman
When you mix a double and an int, the answer is considered a double.
Initially, it's just a little fraction, but yes, it grows up to be a double.
db