<div dir="ltr"><div dir="ltr">On Thu, Dec 12, 2024 at 6:22 PM Ethan McCue <<a href="mailto:ethan@mccue.dev">ethan@mccue.dev</a>> wrote:</div><div class="gmail_quote gmail_quote_container"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Placement in the standard library aside, I think Java needs value types and patterns before a non-throwing version of <font face="monospace">Math.multiplyExact</font><font face="arial, sans-serif"> can be made that achieves the same semantic goals.</font><br><br><font face="monospace">switch (Maths.multiplyExact(a, b)) {</font><br><font face="monospace">    case Product.of(long result) -> {}</font><br><font face="monospace">    case Product.overflow() -> {}</font><br><font face="monospace">}</font></div></blockquote><div><br></div><div>Well, for that matter, if methods that receive lambdas could inline along with the lambda, the error path could just be a passed in lambda. But since we're not there yet I'm looking for short-term options to use the *Exact functions without causing massive overhead when they overflow. </div></div></div>