A must read: What Every Computer Scientist Should Know About Floating-Point Arithmetic

Here are some possible solutions:

1. Don't use float/double at all. Instead, use int/long/BigInteger and...