Search code examples
javadouble

Solve Integer division in floating point context


When doing:

double a = 1000000000 / FPS;

It gives me the warning:

Integer division in floating point context.

How can I solve this?


Solution

  • You have two options. Add .0 at the end as such:

    double a = 1000000000.0 / FPS;
    

    or adding d at the end.

    double a = 1000000000d / FPS;