<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="">On Jun 10, 2016, at 12:38 PM, Xiaodi Wu via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:<div class=""><br class=""><div><blockquote type="cite" class=""><div class=""><div dir="ltr" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: 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;" class=""><div class="gmail_extra"><div class="gmail_quote">On Fri, Jun 10, 2016 at 1:24 PM, Darren Mo via swift-evolution<span class="Apple-converted-space">&nbsp;</span><span dir="ltr" class="">&lt;<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>&gt;</span><span class="Apple-converted-space">&nbsp;</span>wrote:<br class=""><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;"><div style="word-wrap: break-word;" class="">Today, one can get<span class="Apple-converted-space">&nbsp;</span><font face="Menlo" style="font-size: 11px;" class="">max</font>/<font face="Menlo" style="font-size: 11px;" class="">min</font><span class="Apple-converted-space">&nbsp;</span>by doing:<div class=""><br class=""></div><div class=""><font face="Menlo" class=""><span style="font-size: 11px;" class="">let max = Float.greatestFiniteMagnitude</span></font></div><div class=""><font face="Menlo" class=""><span style="font-size: 11px;" class="">let min = -Float.greatestFiniteMagnitude</span></font></div></div></blockquote><div class=""><br class=""></div><div class="">On review of the proposal for the new FloatingPoint, I too commented on the lack of `max` and `min`. You've pointed out the issue with infinity. But also, FLT_MIN (from your local friendly C universe and available in Swift, obviously) is actually the smallest representable positive value, so `Float.min` is of ambiguous meaning. It was therefore decided not to use those words `max` and `min`.</div></div></div></div></div></blockquote><br class=""></div><div>It’s worth noting that this issue has been pretty extensively discussed both on- and off-list. &nbsp;Although convenience is good, the objections to the ambiguity of `.max` and `.min` would be *very* hard to overcome:</div></div><div><br class=""></div><div>– They’re not actually the maximum and minimum values of the type. &nbsp;In particular, that `max(Float.infinity, .max)` wouldn’t be `Float.max` is pretty seriously confusing.</div><div><br class=""></div><div>– The proposed `.min` doesn't align with the meaning of the "float-min-thing” in most other major languages:</div><div><br class=""></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>In&nbsp;C,&nbsp;FLT_MIN is the smallest positive normal</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>In&nbsp;C++, std::numeric_limits&lt;float&gt;::min() is the smallest positive normal</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>In Python, sys.float_info.min is the smallest positive normal</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>In C#, .minValue is documented as “the smallest possible value”, but is actually the value you want, rather than the documented –infinity.</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>In Java, MIN_VALUE is the smallest positive value (including subnormals)</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>In Ruby, MIN is the smallest positive normal</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>In R, double.xmin is the smallest positive normal</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>In MATLAB, realmin is the smallest positive normal</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>Actually,&nbsp;Rust is the only language I know of where `MIN` is the value you want *and* correctly documented as such.</div><div><br class=""></div><div>All that’s not to say that Swift can’t do this, but there’s a lot of opportunity for confusion on this point, and having a very explicit name isn’t really a bad thing.</div><div><br class=""></div><div>– There is also some concern that having `.min` and `.max` with the same names as on Integer types would lead people to try to use them the same way in code, which generally isn’t going to work the way users expect.</div><div><br class=""></div><div>– Steve</div></body></html>