Main Page | Modules | Class List | Directories | File List | Class Members | File Members | Related Pages

util_math.c

Go to the documentation of this file.
00001 /**
00002  * @file   util_math.c
00003  * @author Chris Green <cmg@sourcefire.com>
00004  * @date   Fri Jun 27 10:12:57 2003
00005  * 
00006  * @brief  math related util functions
00007  * 
00008  * Place simple math functions that are useful all over the place
00009  * here.
00010  */
00011 
00012 #include "util_math.h"
00013 
00014 /** 
00015  * Calculate the percentage of something.
00016  *
00017  * If the total is <= 0, we return 0.
00018  * 
00019  * @param amt amount to that you have
00020  * @param total amount there is
00021  * 
00022  * @return a/b * 100
00023  */
00024 double calc_percent(double amt, double total)
00025 {
00026     if(total <= 0.0)
00027         return 0.0;    
00028     
00029     return (amt/total) * 100.0;
00030 }

Generated on Sun May 14 14:51:18 2006 by  doxygen 1.4.2