• Ok - try now!

    Turns out it was two issues :)

    • On nRF52 (which I was using initially) we switched to use the FPU a while back and that messed up how doubles are passed - so code using doubles didn't work reliably. But you wouldn't have hit that (probably the code above would have worked fine on the original Espruino)
    • The type handling of the unary minus (for -8.0) was wrong - and I think that's what hit you

    Running:

    function F(x){
    "compiled";
    return 1/(1.13+Math.exp(-8.0*(x-0.54)))+0.14;
    }
    function G(x){
    return 1/(1.13+Math.exp(-8.0*(x-0.54)))+0.14;
    }
    for (var i=0;i<10;i++) {
      print(F(i),G(i));
    }
    

    Now shows the right values for me

  • we switched to use the FPU a while back and that messed up how doubles are passed

    the -mfloat-abi=softfp was there for a reason so that float could be passed like ints in R0-R4 so that InlineC code could receive float arguments (like this). Is there a reason -mfloat-abi=hard is needed?

    THe -mfloat-abi=softfp -mfpu=fpv4-sp-d16 is a compromise so that both code using softfloats and code with fpu instructions could be linked together.

  • Thank you for the quick response, I will try again and see what happens.

  • just tested it extensivly and it works like a charm! thank you.

About

Avatar for Gordon @Gordon started