<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="">Thanks,<div class=""><br class=""></div><div class="">Will file a bug. </div><div class="">Not sure how the library uses the NSNumber since it's closed source. So it might be other inconsistencies as well..</div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">5. okt. 2016 kl. 13.50 skrev Zhao Xin <<a href="mailto:owenzx@gmail.com" class="">owenzx@gmail.com</a>>:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class="gmail_default" style="font-family:georgia,serif">I think you should file a bug on the inconsistence of `description`. However, the third-party API somehow using the `description` is not a good idea.</div><div class="gmail_default" style="font-family:georgia,serif"><br class=""></div><div class="gmail_default" style="font-family:georgia,serif">Zhaoxin</div></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Wed, Oct 5, 2016 at 5:30 PM, Lars-Jørgen Kristiansen via swift-users <span dir="ltr" class=""><<a href="mailto:swift-users@swift.org" target="_blank" class="">swift-users@swift.org</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class=""><div class="">I'm working with a third party API for some external hardware. One of the functions takes a NSNumber, and it fails to interact correctly with the hardware if I cast a Float too NSNumber, but works as expected if I use Double..</div><div class=""><br class=""></div>I dont know if it is related to NSNumber.stringValue since I dont know what the third part lib does with the NSNumber, but I noticed this:<div class=""><div class=""><div class=""><br class=""></div><div class=""><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(39,42,216)" class=""><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures:no-common-ligatures;color:#ba2da2" class="">let</span><span style="font-variant-ligatures:no-common-ligatures" class=""> float = </span><span style="font-variant-ligatures:no-common-ligatures;color:#272ad8" class="">100_000_00</span><span style="font-variant-ligatures:no-common-ligatures" class=""> </span><span style="font-variant-ligatures:no-common-ligatures;color:#ba2da2" class="">as</span><span style="font-variant-ligatures:no-common-ligatures" class=""> </span><span style="font-variant-ligatures:no-common-ligatures;color:#703daa" class="">Float</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures:no-common-ligatures;color:#ba2da2" class="">let</span><span style="font-variant-ligatures:no-common-ligatures" class=""> floatNumber = </span><span style="font-variant-ligatures:no-common-ligatures;color:#4f8187" class="">float</span><span style="font-variant-ligatures:no-common-ligatures" class=""> </span><span style="font-variant-ligatures:no-common-ligatures;color:#ba2da2" class="">as</span><span style="font-variant-ligatures:no-common-ligatures" class=""> </span><span style="font-variant-ligatures:no-common-ligatures;color:#703daa" class="">NSNumber</span></div><div style="margin: 0px; line-height: normal; min-height: 13px;" class=""><span style="font-variant-ligatures:no-common-ligatures" class=""></span><br class=""></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures:no-common-ligatures;color:#ba2da2" class="">let</span><span style="font-variant-ligatures:no-common-ligatures" class=""> double = </span><span style="font-variant-ligatures:no-common-ligatures;color:#272ad8" class="">100_000_00</span><span style="font-variant-ligatures:no-common-ligatures" class=""> </span><span style="font-variant-ligatures:no-common-ligatures;color:#ba2da2" class="">as</span><span style="font-variant-ligatures:no-common-ligatures" class=""> </span><span style="font-variant-ligatures:no-common-ligatures;color:#703daa" class="">Double</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures:no-common-ligatures;color:#ba2da2" class="">let</span><span style="font-variant-ligatures:no-common-ligatures" class=""> doubleNumer = </span><span style="font-variant-ligatures:no-common-ligatures;color:#4f8187" class="">double</span><span style="font-variant-ligatures:no-common-ligatures" class=""> </span><span style="font-variant-ligatures:no-common-ligatures;color:#ba2da2" class="">as</span><span style="font-variant-ligatures:no-common-ligatures" class=""> </span><span style="font-variant-ligatures:no-common-ligatures;color:#703daa" class="">NSNumber</span></div><div style="margin: 0px; line-height: normal; min-height: 13px;" class=""><span style="font-variant-ligatures:no-common-ligatures" class=""></span><br class=""></div><div style="margin:0px;line-height:normal;color:rgb(0,132,0)" class=""><span style="font-variant-ligatures:no-common-ligatures;color:#4f8187" class="">hardware</span><span style="font-variant-ligatures: no-common-ligatures;" class="">.</span><span style="font-variant-ligatures:no-common-ligatures;color:#31595d" class="">doThing</span><span style="font-variant-ligatures: no-common-ligatures;" class="">(number: </span><span style="font-variant-ligatures:no-common-ligatures;color:#4f8187" class="">floatNumber</span><span style="font-variant-ligatures: no-common-ligatures;" class=""> </span><span style="font-variant-ligatures:no-common-ligatures;color:#ba2da2" class="">as</span><span style="font-variant-ligatures: no-common-ligatures;" class=""> </span><span style="font-variant-ligatures:no-common-ligatures;color:#703daa" class="">NSNumber</span><span style="font-variant-ligatures: no-common-ligatures;" class="">) </span><span style="font-variant-ligatures:no-common-ligatures" class="">// Hardware does not work</span></div><div style="margin:0px;line-height:normal;color:rgb(79,129,135)" class=""><span style="font-variant-ligatures:no-common-ligatures" class="">hardware</span><span style="font-variant-ligatures: no-common-ligatures;" class="">.</span><span style="font-variant-ligatures:no-common-ligatures;color:#31595d" class="">doThing</span><span style="font-variant-ligatures: no-common-ligatures;" class="">(number: </span><span style="font-variant-ligatures:no-common-ligatures" class="">doubleNumer</span><span style="font-variant-ligatures: no-common-ligatures;" class=""> </span><span style="font-variant-ligatures:no-common-ligatures;color:#ba2da2" class="">as</span><span style="font-variant-ligatures: no-common-ligatures;" class=""> </span><span style="font-variant-ligatures:no-common-ligatures;color:#703daa" class="">NSNumber</span><span style="font-variant-ligatures: no-common-ligatures;" class="">) </span><span style="font-variant-ligatures:no-common-ligatures;color:#008400" class="">// Hardware works</span></div><div style="margin: 0px; line-height: normal; min-height: 13px;" class=""><span style="font-variant-ligatures:no-common-ligatures" class=""></span><br class=""></div><div style="margin:0px;line-height:normal;color:rgb(0,132,0)" class=""><span style="font-variant-ligatures:no-common-ligatures" class="">// Also noticed this:</span></div><div style="margin:0px;line-height:normal;color:rgb(79,129,135)" class=""><span style="font-variant-ligatures:no-common-ligatures;color:#d12f1b" class="">"</span><span style="font-variant-ligatures: no-common-ligatures;" class="">\</span><span style="font-variant-ligatures:no-common-ligatures;color:#d12f1b" class="">(</span><span style="font-variant-ligatures:no-common-ligatures" class="">floatNumber</span><span style="font-variant-ligatures:no-common-ligatures;color:#d12f1b" class="">)"</span><span style="font-variant-ligatures: no-common-ligatures;" class=""> </span><span style="font-variant-ligatures:no-common-ligatures;color:#008400" class="">// "1e+07"</span></div><div style="margin:0px;line-height:normal;color:rgb(0,132,0)" class=""><span style="font-variant-ligatures:no-common-ligatures;color:#d12f1b" class="">"</span><span style="font-variant-ligatures: no-common-ligatures;" class="">\</span><span style="font-variant-ligatures:no-common-ligatures;color:#d12f1b" class="">(</span><span style="font-variant-ligatures:no-common-ligatures;color:#4f8187" class="">doubleNumer</span><span style="font-variant-ligatures:no-common-ligatures;color:#d12f1b" class="">)"</span><span style="font-variant-ligatures: no-common-ligatures;" class=""> </span><span style="font-variant-ligatures:no-common-ligatures" class="">// "10000000"</span></div></div></div><div style="margin:0px;line-height:normal" class=""><span style="font-variant-ligatures:no-common-ligatures" class=""><br class=""></span></div><div style="margin:0px;line-height:normal" class=""><span style="font-variant-ligatures:no-common-ligatures" class="">Is this expected behaviour?</span></div></div></div></div><br class="">______________________________<wbr class="">_________________<br class="">
swift-users mailing list<br class="">
<a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a><br class="">
<a href="https://lists.swift.org/mailman/listinfo/swift-users" rel="noreferrer" target="_blank" class="">https://lists.swift.org/<wbr class="">mailman/listinfo/swift-users</a><br class="">
<br class=""></blockquote></div><br class=""></div>
</div></blockquote></div><br class=""></div></body></html>