E
Eric Sosman
MS said:[...]
As far as my Java programming is concerned, I should be careful when
using real numbers and integers together, that the integers are
converted to reals, either done explicitly or by their position in the
evaluation order.
More to the point: You should use the kinds of numbers that
are suited to the calculation at hand. Sometimes these are
integers (of various sizes), sometimes these are reals (of two
precisions), sometimes these are things like BigInteger objects.
And sometimes a calculation needs to mix the effects of more than
one kind of arithmetic: for example, you might use floating-point
arithmetic to compute the 0.52617% monthly interest due on your
mortgage, but then use integer arithmetic to round the product
to a whole number of pennies.
Can you cast in Java --as you can in C-- like this,
which would allow the first formula to work?
double celsius = (double) 5 / (double) 9 * (fahrenheit - (double) 32);
Yes. It strikes me -- no insult intended -- that if you don't
know this sort of thing, you would do well to invest in a Java
textbook. Usenet is a poor channel for transmitting large amounts
of information in comprehensible form.