<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 23 Feb 2017, at 18:40, David Sweeris <<a href="mailto:davesweeris@mac.com" class="">davesweeris@mac.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="content-type" content="text/html; charset=utf-8" class=""><div dir="auto" class=""><div class=""><br class=""></div><div class="">On Feb 22, 2017, at 23:52, Karl Wagner via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:<br class=""><br class=""></div><blockquote type="cite" class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><br class=""><div class=""><blockquote type="cite" class=""><div class=""><div id="edo-original" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><div class=""><blockquote type="cite" style="margin: 1ex 0px 0px; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 0.5ex;" class=""><div class=""><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;"><div style="word-wrap: break-word;" class=""><div class=""><br class=""></div><div class="">Are there Number types which can’t be Comparable?</div></div></blockquote><div class=""><br class=""></div><div class="">Complex numbers. I believe `Number` is designed to allow a complex number type to conform.</div><div class=""> </div></div></div></div></div></blockquote></div></div></div></blockquote></div><br class=""><div class="">Magnitude could be comparable then. For vectors, matrices and complex numbers, “magnitude” typically refers to a scalar. I don’t think we need something broader than that.</div></blockquote><br class=""><div class="">Using magnitude for comparison leads to some decidedly odd places:</div><div class="">let x: Complex = 1</div><div class="">let y: Complex = -2</div><div class="">x < y // returns true</div><div class=""><br class=""></div><div class="">- Dave Sweeris </div></div></div></blockquote></div><div class=""><br class=""></div>Fixed:<div class=""><div class=""><blockquote type="cite" class=""><div dir="auto" class=""><div class="">let x: Complex = 1</div><div class="">let y: Complex = -2</div><div class="">x.magnitude < y.magnitude // returns true</div></div></blockquote><br class=""></div></div><div class="">I don’t mean we should compare all numbers by magnitude, only that the Magnitude associated type be required to be comparable. That way you could, for example, sort things by magnitude (if that’s useful to you).</div><div class=""><br class=""></div><div class="">Given that magnitudes appear to always be scalars (I couldn’t find an exact definition beyond a “norm”, which is a scalar), it seems fair to require them to be comparable.</div><div class=""><br class=""></div><div class="">- Karl</div></body></html>