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));
}
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Ok - try now!
Turns out it was two issues :)
-8.0
) was wrong - and I think that's what hit youRunning:
Now shows the right values for me