<!DOCTYPE html><html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body><div style="font-family: sans-serif;"><div class="markdown" style="white-space: normal;">
<p dir="auto">P.S Sorry, I botched a use case, saying x where I meant y:</p>
<pre style="margin-left: 15px; margin-right: 15px; padding: 5px; background-color: #F7F7F7; border-radius: 5px 5px 5px 5px; overflow-x: auto; max-width: 90vw;"><code style="margin: 0; border-radius: 3px; background-color: #F7F7F7; padding: 0px;"> 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
}
</code></pre>
</div></div></body>
</html>