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>"<i>r</i> = <i>N</i> + <i>x</i>" with <i>x</i> such as "0 <= <i>x</i> < <i>N</i>" 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