<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=""><div><blockquote type="cite" class=""><div class="">On 26 May 2017, at 11:01, Antonino Ficarra via swift-users <<a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="">- Why Swift continues to not support Float80 math functions?<br class="">Example:<br class=""><br class="">print("\( log( Float( 1.0 ) ) )")<br class="">print("\( log( Double( 1.0 ) ) )")<br class="">// print("\( log( Float80( 1.0 ) ) )")<span class="Apple-tab-span" style="white-space:pre">        </span>// don’t compile and logl is unavailable<br class=""></div></div></blockquote><div><br class=""></div><div>In this case, it's because 'log' only is defined for Float and Double:</div><div><br class=""></div><div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><span class="Apple-tab-span" style="white-space:pre">        </span>log(Double) -> Double</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><span class="Apple-tab-span" style="white-space:pre">        </span>log(x: Double) -> Double</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><span class="Apple-tab-span" style="white-space:pre">        </span>log(x: Float) -> Float</span></div><div class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><br class=""></span></div><div class=""><span style="font-variant-ligatures: no-common-ligatures" class="">The problem is that Float80 types are represented in C as long double, and currently the importer doesn't import things with long doubles. As a result, logl doesn't get imported which is why it's not seen:</span></div><div class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><br class=""></span></div><div class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> <b class="">#include</b> <b class=""><math.h></b></span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255); min-height: 13px;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""></span><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="text-decoration: underline ; font-variant-ligatures: no-common-ligatures" class="">double</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> <b class="">log</b>(</span><span style="text-decoration: underline ; font-variant-ligatures: no-common-ligatures" class="">double</span><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="text-decoration: underline ; font-variant-ligatures: no-common-ligatures" class="">x</span><span style="font-variant-ligatures: no-common-ligatures" class="">);</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255); min-height: 13px;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""></span><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="text-decoration: underline ; font-variant-ligatures: no-common-ligatures" class="">long</span><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="text-decoration: underline ; font-variant-ligatures: no-common-ligatures" class="">double</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> <b class="">logl</b>(</span><span style="text-decoration: underline ; font-variant-ligatures: no-common-ligatures" class="">long</span><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="text-decoration: underline ; font-variant-ligatures: no-common-ligatures" class="">double</span><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="text-decoration: underline ; font-variant-ligatures: no-common-ligatures" class="">x</span><span style="font-variant-ligatures: no-common-ligatures" class="">);</span></div><div class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><br class=""></span></div><div class=""><span style="font-variant-ligatures: no-common-ligatures" class="">The ones that do have Float80 support are done by hand, e.g.:</span></div><div class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><br class=""></span></div><div class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><a href="https://github.com/apple/swift/blob/19445cdb0e99eedf22390922e077d86f12123390/stdlib/public/SwiftShims/LibcShims.h#L138" class="">https://github.com/apple/swift/blob/19445cdb0e99eedf22390922e077d86f12123390/stdlib/public/SwiftShims/LibcShims.h#L138</a></span></div></span></div></div><div><br class=""></div><div>The open bug is here, if you want to follow it:</div><div><br class=""></div><div><a href="https://bugs.swift.org/browse/SR-2046" class="">https://bugs.swift.org/browse/SR-2046</a></div><br class=""><blockquote type="cite" class=""><div class=""><div class=""><br class="">- Why min and max continue to not act like fmin and fmax (IEEE 754 standard)?<br class="">Example:<br class=""><br class="">print("\( min( Double.nan,0.0 ) )")<span class="Apple-tab-span" style="white-space:pre">        </span>// print nan (!)<br class="">print("\( min( 0.0,Double.nan ) )")<span class="Apple-tab-span" style="white-space:pre">        </span>// print 0.0<br class="">print("\( max( Double.nan,0.0 ) )")<span class="Apple-tab-span" style="white-space:pre">        </span>// print nan (!)<br class="">print("\( max( 0.0,Double.nan ) )")<span class="Apple-tab-span" style="white-space:pre">        </span>// print 0.0<br class="">print("\n")<br class=""><br class="">print("\( fmin( Double.nan,0.0 ) )")<span class="Apple-tab-span" style="white-space:pre">        </span>// print 0.0<br class="">print("\( fmin( 0.0,Double.nan ) )")<span class="Apple-tab-span" style="white-space:pre">        </span>// print 0.0<br class="">print("\( fmax( Double.nan,0.0 ) )")<span class="Apple-tab-span" style="white-space:pre">        </span>// print 0.0<br class="">print("\( fmax( 0.0,Double.nan ) )")<span class="Apple-tab-span" style="white-space:pre">        </span>// print 0.0<br class=""></div></div></blockquote></div><br class=""><div class="">There is another open bug here:</div><div class=""><br class=""></div><div class=""><a href="https://bugs.swift.org/browse/SR-1011" class="">https://bugs.swift.org/browse/SR-1011</a></div><div class=""><br class=""></div><div class="">Can you add your observations to that?</div><div class=""><br class=""></div><div class="">Thanks,</div><div class=""><br class=""></div><div class="">Alex</div></body></html>