```
if (Double.isNaN(v1)) {
    return Double.isNaN(v2) ? 0 : 1;
}
```