P.S Sorry, I botched a use case, saying x where I meant y:

```
   long x = …, y = a*x*x + b*x + c;
   double xf = x, yf = a*xf*xf + b*xf + c;
   double yc = clamp(yf, Long.MIN_VALUE, Long.MAX_VALUE);
   boolean saturated = false;
   if (yc != yf) {   // error processing
      saturated = true;  // or throw an exception
      y = yc;  // saturate towards the required magnitude
   }
```


Reply via email to