Question: ```
import java.util.*;
import java.lang.*;
import java.io.*;

public class MyClass {
    public static void main (final String[] args) {
        float distanceInMeters = 0.0f;
        long time = 1439230171182L;
        long previousTime = 1439230111554L;
        float speed = (distanceInMeters / 1000) / ((time - previousTime)/3600000);
        System.out.println(speed);
    }
}

```

This calculation returns "NaN". Does anyone know why?

Answer: 
You're dividing by zero always. You're subtracting two longs then doing integer division. Those two longs will be less than 3600000, so your result will be `(distanceInMeters / 1000) / 0` = `NaN`
The solution is to add a float cast like this:

```
float speed = (distanceInMeters / 1000) / ((float)(time - previousTime)/3600000);

```

or like this:

```
float speed = (distanceInMeters / 1000) / ((time - previousTime)/3600000.0f);

```

I forgot about the Integer division in Java. Probably because I wrote a lot of JavaScript code previously.