diff -r f433193f7bb6 -r 08c92cb740b9 www/js/global.js --- a/www/js/global.js Sat Nov 17 15:58:13 2018 +0100 +++ b/www/js/global.js Sat Nov 17 19:44:39 2018 +0100 @@ -84,15 +84,20 @@ function ebc_to_srm(ebc) { - return -1.32303E-12 * Math.pow(ebc, 4) - 0.00000000291515 * Math.pow(ebc, 3) + 0.00000818515 * Math.pow(ebc, 2) + 0.372038 * ebc + 0.596351; + var srm = -1.32303E-12 * Math.pow(ebc, 4) - 0.00000000291515 * Math.pow(ebc, 3) + 0.00000818515 * Math.pow(ebc, 2) + 0.372038 * ebc + 0.596351; + if ((ebc < 0) || (srm < 0)) + console.log("ebc_to_srm("+ebc+") = "+srm); + return srm } function srm_to_ebc(srm) { - var ebc = 0.000000000176506 * Math.pow(srm, 4) + 0.000000154529 * Math.pow(srm, 3) - 0.000159428 * Math.pow(srm, 2) + 2.68837 * srm - 1.6004; - return Math.round(ebc); + var ebc = Math.round(0.000000000176506 * Math.pow(srm, 4) + 0.000000154529 * Math.pow(srm, 3) - 0.000159428 * Math.pow(srm, 2) + 2.68837 * srm - 1.6004); + if ((ebc < 0) || (srm < 0)) + console.log("srm_to_ebc("+srm+") = "+ebc); + return ebc; }