Question: I need to write a small Java program that deals with calculations involving money. Therefore it needs to have accuracy. (Eg: No `float`/`double` variables, only `long`).

Unfortunately, the original value I need to use is imported through a method which can only read variables as "double".

Now, I tried casting it to a `long` using a method similar to:

```
double importedValue = x;
double importedValueConverted = (long) x;

```

However, when I try dividing importedValueConverted by another "long" variable I get:

> 
> required: long 
>  found: double 
>  error: possible loss of precision
> 
> 
> 

Why is that?

Answer: 
Forget all the casting business. If you are working with financial calculations, you can directly use BigDecimal to wrap the doubles returned by your so called method and use an appropriate rounding mechanism provided by BigDecimal that suits your needs.
Why not look at [BigDecimal](http://docs.oracle.com/javase/1.4.2/docs/api/java/math/BigDecimal.html#BigDecimal%28double%29). It works well when I have used it. Be careful using the Double ctor though as Double is not that precise (eg it cannot accurately store 0.1). It may be more useful to use the [String](http://docs.oracle.com/javase/1.4.2/docs/api/java/math/BigDecimal.html#BigDecimal%28java.lang.String%29) ctor for BigDecimal