Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals   Examples  

my_math.c

Go to the documentation of this file.
00001 /*! \file my_math.c
00002     This file implements various specific mathematical tools.
00003  */
00004 
00005 #include "my_math.h"
00006 
00007 /*! \brief Given two integers <i>N</i> and <i>p</i>, the function returns the integer <i>r</i> such as:<BR>
00008            <UL>
00009               <li><i>r</i> is a multiple of <i>p</i>.
00010               <li>&quot;<i>r</i> = <i>N</i> + <i>x</i>&quot; with <i>x</i> such as &quot;0 &lt;= <i>x</i> &lt; <i>N</i>&quot;
00011            </UL>
00012            For example, if <i>N</i>=2 and <i>p</i>=4, then <i>r</i>=4.
00013     \param value This parameter matches <i>N</i> in the function's description above.
00014     \param factor This parameter matches <i>p</i> in the function's description above.
00015     \return The function returns the multiple of <i>factor</i>, that is closest to <i>value</i> (greater that <i>value</i>).
00016  */
00017 
00018 unsigned int round_to_multiple_of (unsigned int value, unsigned int factor)
00019 {
00020     unsigned int d;
00021 
00022     d = value / factor;
00023 
00024     if ((d * factor) != value) { d++; }
00025     return d * factor;
00026 }
00027 
00028 
00029 
00030 
00031 
00032 

Generated on Thu Apr 3 16:23:43 2003 for Common_C_libraries by doxygen1.3-rc1