diff -r f433193f7bb6 -r 08c92cb740b9 www/includes/formulas.php --- a/www/includes/formulas.php Sat Nov 17 15:58:13 2018 +0100 +++ b/www/includes/formulas.php Sat Nov 17 19:44:39 2018 +0100 @@ -21,20 +21,21 @@ function ebc_to_srm($ebc) { - // Srm = -1.32303E-12*Ebc4-0.00000000291515*Ebc3+0.00000818515*Ebc2+0.372038*Ebc+0.596351 - return -1.32303E-12 * pow($ebc, 4) - 0.00000000291515 * pow($ebc, 3) + 0.00000818515 * pow($ebc, 2) + 0.372038 * $ebc + 0.596351; - // return $ebc * 0.508; + $srm = -1.32303E-12 * pow($ebc, 4) - 0.00000000291515 * pow($ebc, 3) + 0.00000818515 * pow($ebc, 2) + 0.372038 * $ebc + 0.596351; + if (($ebc < 0) || ($srm < 0)) + syslog(LOG_NOTICE, "ebc_to_srm(".$ebc.") = ".$srm); + return $srm; } function srm_to_ebc($srm) { - // EBC = 0.000000000176506*Srm4+ 0.000000154529*Srm3-0.000159428*Srm2+2.68837*Srm-1.6004 - // // Formule van Adrie Otten. brouwhulp. - $ebc = 0.000000000176506 * pow($srm, 4) + 0.000000154529 * pow($srm, 3) - 0.000159428 * pow($srm, 2) + 2.68837 * $srm - 1.6004; - return round($ebc); + $ebc = round( 0.000000000176506 * pow($srm, 4) + 0.000000154529 * pow($srm, 3) - 0.000159428 * pow($srm, 2) + 2.68837 * $srm - 1.6004 ); + if (($ebc < 0) || ($srm < 0)) + syslog(LOG_NOTICE, "srm_to_ebc(".$srm.") = ".$ebc); + return $ebc; }