isn't that what signalling nan is supposed to be for? ever used that?

something like:
    
    
    import fenv,strutils
    template sNaN:float = cast[float](0xfff0_0000_0000_0001'u64)
    
    proc initOrDont(f: var float) =
      if false: f = 1.0
    
    var myF = sNaN
    
    initOrDont(myF)
    
    let x = NaN * NaN
    assert fetestexcept(FE_INVALID)==0 #no effect with NaN
    
    let x = myF + 1.0 #triggers on any operation
    if fetestexcept(FE_INVALID) != 0: raise newException(ValueError, "sNaN 
detected")
    
    
    Run

Reply via email to