<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Mar 2, 2016, at 12:45 PM, David Sweeris <<a href="mailto:davesweeris@mac.com" class="">davesweeris@mac.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="" style="font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; margin: 0px; line-height: normal; font-family: Menlo;"><span class="" style="color: rgb(187, 44, 162);">func</span><span class=""><span class="Apple-converted-space"> </span>== (lhs:<span class="Apple-converted-space"> </span></span><span class="" style="color: rgb(112, 61, 170);">Double</span><span class="">, rhs: (value:<span class="Apple-converted-space"> </span></span><span class="" style="color: rgb(112, 61, 170);">Double</span><span class="">, tolerance:<span class="Apple-converted-space"> </span></span><span class="" style="color: rgb(112, 61, 170);">Double</span><span class="">)) -><span class="Apple-converted-space"> </span></span><span class="" style="color: rgb(112, 61, 170);">Bool</span><span class=""><span class="Apple-converted-space"> </span>{</span></div><div class="" style="font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; margin: 0px; line-height: normal; font-family: Menlo;"><span class=""> <span class="Apple-converted-space"> </span></span><span class="" style="color: rgb(187, 44, 162);">return</span><span class=""><span class="Apple-converted-space"> </span>((rhs.value - rhs.tolerance)...(rhs.value + rhs.tolerance)) ~= lhs</span></div><div class="" style="font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; margin: 0px; line-height: normal; font-family: Menlo;"><span class="">}</span></div><div class="" style="font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; margin: 0px; line-height: normal; font-family: Menlo; color: rgb(39, 42, 216);"><span class="">3.0</span><span class="" style=""><span class="Apple-converted-space"> </span></span><span class="" style="color: rgb(49, 89, 93);">==</span><span class="" style=""><span class="Apple-converted-space"> </span></span><span class="">3.01</span><span class="" style=""><span class="Apple-converted-space"> </span></span><span class="" style="color: rgb(49, 89, 93);">≈</span><span class="" style=""><span class="Apple-converted-space"> </span></span><span class="">0.001</span><span class="" style=""><span class="Apple-converted-space"> </span></span><span class="" style="color: rgb(0, 132, 0);">// false</span></div><div class="" style="font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; margin: 0px; line-height: normal; font-family: Menlo; color: rgb(39, 42, 216);"><span class="">3.0</span><span class="" style=""><span class="Apple-converted-space"> </span></span><span class="" style="color: rgb(49, 89, 93);">==</span><span class="" style=""><span class="Apple-converted-space"> </span></span><span class="">3.01</span><span class="" style=""><span class="Apple-converted-space"> </span></span><span class="" style="color: rgb(49, 89, 93);">≈</span><span class="" style=""><span class="Apple-converted-space"> </span></span><span class="">0.01</span><span class="" style=""><span class="Apple-converted-space"> </span></span><span class="" style="color: rgb(0, 132, 0);">// true</span></div><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span class="" style="color: rgb(0, 132, 0);"><br class=""></span></div><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span class="">I tried using "ε", which is the standard symbol for "error", but that doesn't seem to be a valid operator character. "≈" (⌥-x, at least on a mac) is the only other one that seemed to make sense, with the possible exception of "∂", but I don't think that's as well-known.<br class=""></span></div></div></blockquote></div><br class=""><div class="">That's cute. In a real implementation of tolerant comparison, you'd want to scale the tolerance to the magnitude of the larger operand, though. (See <a href="http://code.jsoftware.com/wiki/Essays/Tolerant_Comparison" class="">http://code.jsoftware.com/wiki/Essays/Tolerant_Comparison</a> .)</div><div class=""><br class=""></div><div class="">-Joe</div></body></html>