Make duplicate script compatible with Python 3
[wdl/wdl-ol.git] / WDL / db2val.h
bloba0a0df1203f46765bfca5161a3b73c9db64faed0
1 #ifndef _WDL_DB2VAL_H_
2 #define _WDL_DB2VAL_H_
4 #include <math.h>
6 #define TWENTY_OVER_LN10 8.6858896380650365530225783783321
7 #define LN10_OVER_TWENTY 0.11512925464970228420089957273422
8 #define DB2VAL(x) exp((x)*LN10_OVER_TWENTY)
10 static inline double VAL2DB(double x)
12 if (x < 0.0000000298023223876953125) return -150.0;
13 double v=log(x)*TWENTY_OVER_LN10;
14 return v<-150.0?-150.0:v;
17 static inline double VAL2DB_EX(double x, double mindb)
19 return x <= DB2VAL(mindb) ? mindb : (log(x)*TWENTY_OVER_LN10);
22 #endif