<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">Should these be consistent? </div><div class=""><br class=""></div><div class="">All crashing or none crashing?</div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo; color: rgb(62, 30, 129); background-color: rgb(255, 255, 255);" class="">print<span style="color: #000000" class="">(</span>abs<span style="color: #000000" class="">(</span><span style="color: #703daa" class="">Int8</span><span style="color: #000000" class="">.</span><span style="color: #703daa" class="">min</span><span style="color: #000000" class="">)) </span><span style="color: #008400" class="">// crash</span></div></div><div class=""><span style="color: #008400" class=""><br class=""></span></div><div class=""><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo; color: rgb(62, 30, 129); background-color: rgb(255, 255, 255);" class="">print<span style="color: #000000" class="">(</span>abs<span style="color: #000000" class="">(</span><span style="color: #703daa" class="">Int16</span><span style="color: #000000" class="">.</span><span style="color: #703daa" class="">min</span><span style="color: #000000" class="">)) // crash</span></div></div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo; color: rgb(62, 30, 129); background-color: rgb(255, 255, 255);" class=""><span style="color: #000000" class=""><br class=""></span></div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo; color: rgb(62, 30, 129); background-color: rgb(255, 255, 255);" class=""><div style="margin: 0px; line-height: normal; color: rgb(0, 132, 0);" class=""><span style="color: #3e1e81" class="">print</span><span style="color: #000000" class="">(</span><span style="color: #3e1e81" class="">abs</span><span style="color: #000000" class="">(</span><span style="color: #703daa" class="">Int32</span><span style="color: #000000" class="">.</span><span style="color: #703daa" class="">min</span><span style="color: #000000" class="">)) </span>// prints -2147483648</div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 12px; line-height: normal; font-family: Helvetica; min-height: 14px;" class=""><span style="font-family: Menlo; font-size: 14px; text-decoration: underline;" class="">print</span><span style="font-family: Menlo; font-size: 14px; text-decoration: underline; color: rgb(0, 0, 0);" class="">(</span><span style="font-family: Menlo; font-size: 14px; text-decoration: underline;" class="">abs</span><span style="font-family: Menlo; font-size: 14px; text-decoration: underline; color: rgb(0, 0, 0);" class="">(</span><span style="font-family: Menlo; font-size: 14px; text-decoration: underline; color: rgb(112, 61, 170);" class="">Int64</span><span style="font-family: Menlo; font-size: 14px; text-decoration: underline; color: rgb(0, 0, 0);" class="">.</span><span style="font-family: Menlo; font-size: 14px; text-decoration: underline; color: rgb(112, 61, 170);" class="">min</span><span style="font-family: Menlo; font-size: 14px; text-decoration: underline; color: rgb(0, 0, 0);" class="">)) </span><span style="font-family: Menlo; font-size: 14px; text-decoration: underline; color: rgb(0, 132, 0);" class="">// cra</span><span style="font-family: Menlo; font-size: 14px; color: rgb(0, 132, 0);" class="">sh</span></div></div></div><div class=""><span style="color: #000000" class=""><br class=""></span></div><div class=""><span style="color: #000000" class="">Should this be reported by Radar or another mechanism?</span></div><div class=""><span style="color: #000000" class=""><br class=""></span></div><div class=""><span style="color: #000000" class="">I'm using this as a replacement:</span></div><div class=""><span style="color: #000000" class=""><br class=""></span></div><div class=""><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo; color: rgb(112, 61, 170); background-color: rgb(255, 255, 255);" class=""><span style="color: #ba2da2" class="">func</span><span style="color: #000000" class=""> safeAbs<T: </span>SignedInteger<span style="color: #000000" class=""> & </span>FixedWidthInteger<span style="color: #000000" class="">>(</span><span style="color: #ba2da2" class="">_</span><span style="color: #000000" class=""> i: </span><span style="color: #4f8187" class="">T</span><span style="color: #000000" class="">) -> </span><span style="color: #4f8187" class="">T</span><span style="color: #000000" class=""> {</span></div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""> <span style="color: #ba2da2" class="">if</span> i >= <span style="color: #272ad8" class="">0</span> {</div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""> <span style="color: #ba2da2" class="">return</span> i</div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); background-color: rgb(255, 255, 255);" class=""><span style="color: #000000" class=""> } </span><span style="color: #ba2da2" class="">else</span><span style="color: #000000" class=""> </span><span style="color: #ba2da2" class="">if</span><span style="color: #000000" class=""> i == </span><span style="color: #4f8187" class="">T</span><span style="color: #000000" class="">.</span><span style="color: #703daa" class="">min</span><span style="color: #000000" class=""> { </span>// can't negate this value</div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); background-color: rgb(255, 255, 255);" class=""><span style="color: #000000" class=""> </span>// return i // unconverted, violates postcondition, assert(result >= 0)</div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); background-color: rgb(255, 255, 255);" class=""><span style="color: #000000" class=""> </span>// return 0 // or return an arbitrary "safe" value</div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); background-color: rgb(255, 255, 255);" class=""><span style="color: #000000" class=""> </span><span style="color: #ba2da2" class="">return</span><span style="color: #000000" class=""> </span><span style="color: #272ad8" class="">-(1</span><span style="color: #000000" class="">+i) </span>// or return approximately the right value</div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""> } <span style="color: #ba2da2" class="">else</span> {</div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""> <span style="color: #ba2da2" class="">return</span> -i</div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""> }</div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class="">}</div><div style="margin: 0px; font-size: 12px; line-height: normal; font-family: Helvetica; background-color: rgb(255, 255, 255); min-height: 14px;" class=""><br class=""></div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo; color: rgb(49, 89, 93); background-color: rgb(255, 255, 255);" class=""><span style="color: #3e1e81" class="">print</span><span style="color: #000000" class="">(</span>safeAbs<span style="color: #000000" class="">(</span><span style="color: #703daa" class="">Int8</span><span style="color: #000000" class="">.</span><span style="color: #703daa" class="">min</span><span style="color: #000000" class="">)) // prints </span><b class="">127 </b></div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span style="color: rgb(62, 30, 129);" class="">print</span><span style="color: rgb(0, 0, 0);" class="">(</span><span style="color: rgb(49, 89, 93);" class="">safeAbs</span><span style="color: rgb(0, 0, 0);" class="">(</span><font color="#703daa" class="">Int16</font><span style="color: rgb(0, 0, 0);" class="">.</span><font color="#703daa" class="">min</font><span style="color: rgb(0, 0, 0);" class="">)) // </span>prints 32767</div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span style="color: rgb(62, 30, 129);" class="">print</span><span style="color: rgb(0, 0, 0);" class="">(</span><span style="color: rgb(49, 89, 93);" class="">safeAbs</span><span style="color: rgb(0, 0, 0);" class="">(</span><font color="#703daa" class="">Int32</font><span style="color: rgb(0, 0, 0);" class="">.</span><font color="#703daa" class="">min</font><span style="color: rgb(0, 0, 0);" class="">)) // </span>prints 2147483647</div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span style="color: rgb(62, 30, 129);" class="">print</span><span style="color: rgb(0, 0, 0);" class="">(</span><span style="color: rgb(49, 89, 93);" class="">safeAbs</span><span style="color: rgb(0, 0, 0);" class="">(</span><font color="#703daa" class="">Int64</font><span style="color: rgb(0, 0, 0);" class="">.</span><font color="#703daa" class="">min</font><span style="color: rgb(0, 0, 0);" class="">)) // </span>prints 9223372036854775807</div></div><div class=""><span style="color: #000000" class=""><br class=""></span></div></body></html>