<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="">Hello,<div class=""><br class=""></div><div class="">Appr. a year ago I suggested to allow implicit conversion between floating point number types,</div><div class="">that is between Float, CGFloat &nbsp;Double..Float80 …&nbsp;</div><div class="">(Note that CGFloat IS a Double on 64-bit systems btw),</div><div class=""><br class=""></div><div class="">E.g I am currently making things using SceneKit 3D, wich obviously involves a lot</div><div class="">of floating point arithmetic, using functions from several libraries where</div><div class="">some use Floats, others Double or CGFloat etc..&nbsp;</div><div class="">That wouldn't be so bad, were it not that all the work that I do contains</div><div class="">a lot of of unavoidable explicit Floating point conversions like so:</div><div class=""><br class=""></div><div class="">let&nbsp;ypos = CGFloat(1080.0&nbsp;- (yGravity * yfactor)) &nbsp;// double in expression to CGFloat</div><div class=""><br class=""></div><div class="">camera1.reorientate (<br class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;SCNVector3(x: Float(motionGravityY *&nbsp;&nbsp;-0.08),<br class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;y: Float(motionGravityX *&nbsp;&nbsp;-0.1),<br class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;z: roll )&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;)</div><div class=""><br class=""></div><div class="">This is tedious and makes source less readable.</div><div class=""><br class=""></div><div class="">With implicit floating point number conversion It could be like this</div><div class=""><br class=""></div><div class="">var float1,float2,float3: Float</div><div class="">var double1,double2,double3: Double</div><div class="">var cgfloat1, cgfloat2, ccgfloat3 CGFloat&nbsp;</div><div class=""><br class=""></div><div class="">float1 = cgfloat2 * double3 + float1 &nbsp; // implicit conversion should be allowed (whereby everything&nbsp;</div><div class="">in the expression should be promoted to the highest precision var in the expression (Double here) &nbsp;</div><div class="">which then would be type wise: &nbsp;&nbsp;</div><div class="">Float = CGFloat(implicitly. promoted to Double) * Double) + Float &nbsp;(imp. promoted to Double)&nbsp;</div><div class=""><br class=""></div><div class="">Also, implicit conversion when passing function parameters would be very convenient as well e.g.</div><div class=""><br class=""></div><div class="">This function:&nbsp;</div><div class="">&nbsp; &nbsp; &nbsp; &nbsp;func someMath(p1: Float, p2: Float, result: Inout Float) {…}</div><div class=""><br class=""></div><div class="">could then be called without explicit conversion like so:</div><div class=""><br class=""></div><div class="">&nbsp; &nbsp; &nbsp; &nbsp; someMath(p1: double1, p2: cgfloat1, &nbsp;result: &amp;double3) &nbsp;&nbsp;</div><div class=""><br class=""></div><div class="">// yes, also on inout parameters. This is done 2 times during the call and when returning.</div><div class="">&nbsp;</div><div class=""><br class=""></div><div class="">As I vaguely remember &nbsp;there were objections to this implicit conversion of FP numbers,</div><div class="">because this was (as viewed back then) too complicated to implement?</div><div class=""><br class=""></div><div class="">Note that people that regularly work with floating point numbers are</div><div class="">well aware about having a precision loss when e.g. &nbsp;when converting</div><div class="">from Double to Float, or indeed between other numerical types as well&nbsp;</div><div class="">no problem.</div><div class=""><br class=""></div><div class="">For those not desiring such flexibility, there could be a new compiler option(s)</div><div class="">that disallows this freedom of implicit floating point number conversion.</div><div class=""><br class=""></div><div class="">or have at least (suppressible) compiler warnings about precision loss,</div><div class="">e.g when doing this: float = double..&nbsp;</div><div class=""><br class=""></div><div class="">?</div><div class=""><br class=""></div><div class="">Kind Regards from Speyer, Germany</div><div class="">TedvG</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">&nbsp;&nbsp;</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div></body></html>