<div dir="ltr"><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></div><div class="gmail_default" style="font-family:georgia,serif">Zhaoxin</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Oct 5, 2016 at 5:30 PM, Lars-Jørgen Kristiansen via swift-users <span dir="ltr">&lt;<a href="mailto:swift-users@swift.org" target="_blank">swift-users@swift.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div>I&#39;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><br></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><div><div><br></div><div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(39,42,216)"><div style="margin:0px;line-height:normal;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures;color:#ba2da2">let</span><span style="font-variant-ligatures:no-common-ligatures"> float = </span><span style="font-variant-ligatures:no-common-ligatures;color:#272ad8">100_000_00</span><span style="font-variant-ligatures:no-common-ligatures"> </span><span style="font-variant-ligatures:no-common-ligatures;color:#ba2da2">as</span><span style="font-variant-ligatures:no-common-ligatures"> </span><span style="font-variant-ligatures:no-common-ligatures;color:#703daa">Float</span></div><div style="margin:0px;line-height:normal;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures;color:#ba2da2">let</span><span style="font-variant-ligatures:no-common-ligatures"> floatNumber = </span><span style="font-variant-ligatures:no-common-ligatures;color:#4f8187">float</span><span style="font-variant-ligatures:no-common-ligatures"> </span><span style="font-variant-ligatures:no-common-ligatures;color:#ba2da2">as</span><span style="font-variant-ligatures:no-common-ligatures"> </span><span style="font-variant-ligatures:no-common-ligatures;color:#703daa">NSNumber</span></div><div style="margin:0px;line-height:normal;color:rgb(0,0,0);min-height:13px"><span style="font-variant-ligatures:no-common-ligatures"></span><br></div><div style="margin:0px;line-height:normal;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures;color:#ba2da2">let</span><span style="font-variant-ligatures:no-common-ligatures"> double = </span><span style="font-variant-ligatures:no-common-ligatures;color:#272ad8">100_000_00</span><span style="font-variant-ligatures:no-common-ligatures"> </span><span style="font-variant-ligatures:no-common-ligatures;color:#ba2da2">as</span><span style="font-variant-ligatures:no-common-ligatures"> </span><span style="font-variant-ligatures:no-common-ligatures;color:#703daa">Double</span></div><div style="margin:0px;line-height:normal;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures;color:#ba2da2">let</span><span style="font-variant-ligatures:no-common-ligatures"> doubleNumer = </span><span style="font-variant-ligatures:no-common-ligatures;color:#4f8187">double</span><span style="font-variant-ligatures:no-common-ligatures"> </span><span style="font-variant-ligatures:no-common-ligatures;color:#ba2da2">as</span><span style="font-variant-ligatures:no-common-ligatures"> </span><span style="font-variant-ligatures:no-common-ligatures;color:#703daa">NSNumber</span></div><div style="margin:0px;line-height:normal;color:rgb(0,0,0);min-height:13px"><span style="font-variant-ligatures:no-common-ligatures"></span><br></div><div style="margin:0px;line-height:normal;color:rgb(0,132,0)"><span style="font-variant-ligatures:no-common-ligatures;color:#4f8187">hardware</span><span style="font-variant-ligatures:no-common-ligatures;color:#000000">.</span><span style="font-variant-ligatures:no-common-ligatures;color:#31595d">doThing</span><span style="font-variant-ligatures:no-common-ligatures;color:#000000">(number: </span><span style="font-variant-ligatures:no-common-ligatures;color:#4f8187">floatNumber</span><span style="font-variant-ligatures:no-common-ligatures;color:#000000"> </span><span style="font-variant-ligatures:no-common-ligatures;color:#ba2da2">as</span><span style="font-variant-ligatures:no-common-ligatures;color:#000000"> </span><span style="font-variant-ligatures:no-common-ligatures;color:#703daa">NSNumber</span><span style="font-variant-ligatures:no-common-ligatures;color:#000000">) </span><span style="font-variant-ligatures:no-common-ligatures">// Hardware does not work</span></div><div style="margin:0px;line-height:normal;color:rgb(79,129,135)"><span style="font-variant-ligatures:no-common-ligatures">hardware</span><span style="font-variant-ligatures:no-common-ligatures;color:#000000">.</span><span style="font-variant-ligatures:no-common-ligatures;color:#31595d">doThing</span><span style="font-variant-ligatures:no-common-ligatures;color:#000000">(number: </span><span style="font-variant-ligatures:no-common-ligatures">doubleNumer</span><span style="font-variant-ligatures:no-common-ligatures;color:#000000"> </span><span style="font-variant-ligatures:no-common-ligatures;color:#ba2da2">as</span><span style="font-variant-ligatures:no-common-ligatures;color:#000000"> </span><span style="font-variant-ligatures:no-common-ligatures;color:#703daa">NSNumber</span><span style="font-variant-ligatures:no-common-ligatures;color:#000000">) </span><span style="font-variant-ligatures:no-common-ligatures;color:#008400">// Hardware works</span></div><div style="margin:0px;line-height:normal;color:rgb(0,0,0);min-height:13px"><span style="font-variant-ligatures:no-common-ligatures"></span><br></div><div style="margin:0px;line-height:normal;color:rgb(0,132,0)"><span style="font-variant-ligatures:no-common-ligatures">// Also noticed this:</span></div><div style="margin:0px;line-height:normal;color:rgb(79,129,135)"><span style="font-variant-ligatures:no-common-ligatures;color:#d12f1b">&quot;</span><span style="font-variant-ligatures:no-common-ligatures;color:#000000">\</span><span style="font-variant-ligatures:no-common-ligatures;color:#d12f1b">(</span><span style="font-variant-ligatures:no-common-ligatures">floatNumber</span><span style="font-variant-ligatures:no-common-ligatures;color:#d12f1b">)&quot;</span><span style="font-variant-ligatures:no-common-ligatures;color:#000000"> </span><span style="font-variant-ligatures:no-common-ligatures;color:#008400">// &quot;1e+07&quot;</span></div><div style="margin:0px;line-height:normal;color:rgb(0,132,0)"><span style="font-variant-ligatures:no-common-ligatures;color:#d12f1b">&quot;</span><span style="font-variant-ligatures:no-common-ligatures;color:#000000">\</span><span style="font-variant-ligatures:no-common-ligatures;color:#d12f1b">(</span><span style="font-variant-ligatures:no-common-ligatures;color:#4f8187">doubleNumer</span><span style="font-variant-ligatures:no-common-ligatures;color:#d12f1b">)&quot;</span><span style="font-variant-ligatures:no-common-ligatures;color:#000000"> </span><span style="font-variant-ligatures:no-common-ligatures">// &quot;10000000&quot;</span></div></div></div><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures"><br></span></div><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures">Is this expected behaviour?</span></div></div></div></div><br>______________________________<wbr>_________________<br>
swift-users mailing list<br>
<a href="mailto:swift-users@swift.org">swift-users@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-users" rel="noreferrer" target="_blank">https://lists.swift.org/<wbr>mailman/listinfo/swift-users</a><br>
<br></blockquote></div><br></div>