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.
If you wanna cast double to long you do below.

```
    double importedValue = 8.0;
    long importedValueConverted = (long) 8.0;
    System.out.println(importedValueConverted/(long)8);

```

OUTPUT: 1

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

```

you were trying to cast a double to long and reassign the casted value to a double. you should assign it to long.