float2.c (411B)
1 #include <math.h> 2 #include <float.h> 3 4 #define sreLOG2(x) ((x) > 0 ? log(x) * 1.44269504 : -9999.) 5 6 /* Function: Prob2Score() 7 * 8 * Purpose: Convert a probability to a scaled integer log_2 odds score. 9 * Round to nearest integer (i.e. note use of +0.5 and floor()) 10 * Return the score. 11 */ 12 int Prob2Score(float p, float null) 13 { 14 if (p == 0.0) return 1; 15 return (int) floor(log(1)); 16 } 17