[swift-evolution] implementing real (floating point) number comparison tolerance as a compiler directive.

ted van gaalen tedvgiosdev at gmail.com
Tue Mar 1 12:28:10 CST 2016

in relation to my message about handling floating point number comparisation tolerance in e.g. a .stride function, wouldn't this be better handled by a compiler directive?

For example:

    @floatingPointComparisonTolerance = 0.001
     // all source that follows this will be compiled with this value
     // until reset or another value is specified with this directive.

    if fp1 == fp2    // will be evaluated with the above specified tolerance. 

    for v in minival.stride(to: maxival, by: 0.1)

    for e from -1.0 to 123.45 by 0.1       // also in loops of course, as here in the for loop       variant I will propose.


At any time, you should be able to change @floatingPointComparisonTolerance,
which will have its effect on source lines that follow it.


More information about the swift-evolution mailing list