<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="">+CC Steve<div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Mar 30, 2016, at 6:09 AM, Ted F.A. van Gaalen via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">There is still no fixed decimal numerical type available in Swift!</div><div class=""><br class=""></div><div class="">It should be &nbsp;implemented *as soon as possible*&nbsp;</div><div class="">because the fixed decimal type is really needed&nbsp;</div><div class="">for applications working with financial and statistical data!</div><div class=""><br class=""></div><div class="">E.g.&nbsp;</div><div class="">var depositPromille: Decimal(10,3) = -1234.56</div><div class="">typealias &nbsp;Money = Decimal(20,2)&nbsp;</div><div class=""><br class=""></div><div class="">Important: Implementation should be on a low level</div><div class="">and must be very, very efficient!</div><div class="">This is because usually in financial applications&nbsp;</div><div class="">very large amounts of data (e.g. bank accounts) are processed.&nbsp;</div><div class=""><br class=""></div><div class="">I’d suggest that Swift could deploy already existing</div><div class="">Fixed Decimal library functions available.&nbsp;</div><div class="">In fact, many do exist, for example here:</div><div class=""><a href="http://gcc.gnu.org/onlinedocs/gcc-4.6.0/libstdc++/api/a01152.html" class="">http://gcc.gnu.org/onlinedocs/gcc-4.6.0/libstdc++/api/a01152.html</a>&nbsp;</div><div class=""><br class=""></div><div class="">Of course, the fixed decimal type is also available in most relational databases,</div><div class="">currently there is no 1:1 way to get this type of data &nbsp; DB &lt;—&gt; Swift,</div><div class="">and to process it easily in Swift. One now has to convert it e.g.</div><div class="">to large integers, thereby also somehow remembering the decimal fraction.</div><div class="">Yes, one could write a class/struct for it, but one also has</div><div class="">to implement all the arithmetic involved, with also needs&nbsp;</div><div class="">rounding, truncation, etc. It would also be too slow.</div><div class=""><br class=""></div><div class="">For those still considering using floating point types</div><div class="">for this purpose e.g. Double: Forget it, because&nbsp;</div><div class="">floating point types don’t have the required exact precision.</div><div class="">E.g. € 234,565,098.01 &nbsp; // the one cent at the end is important!</div><div class=""><br class=""></div><div class="">&nbsp;&nbsp;</div><div class="">For some idea &nbsp;on how this could be implemented in the Swift language</div><div class="">please read a PL/1 manual, like this one:&nbsp;</div><div class=""><br class=""></div><div class=""><a href="http://www.ibm.com/support/knowledgecenter/#!/SSY2V3_4.3.0/com.ibm.entpli.doc_4.3/lr/preface_plugin.htm" class="">http://www.ibm.com/support/knowledgecenter/#!/SSY2V3_4.3.0/com.ibm.entpli.doc_4.3/lr/preface_plugin.htm</a></div><div class=""><br class=""></div><div class="">especially under sub-topic “Data elements”&nbsp;</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">Kind Regards</div><div class="">TedvG</div></div>_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-evolution<br class=""></div></blockquote></div><br class=""></div></body></html>