diff --git a/src/types.cpp b/src/types.cpp index 1e0ef0bb..c53cd54e 100644 --- a/src/types.cpp +++ b/src/types.cpp @@ -20,14 +20,14 @@ */ /* File: types.cpp - Version: $Name: $ $Revision: 1.5 $ + Version: $Name: $ $Revision: 1.6 $ Author(s): Andreas Huggel (ahu) History: 26-Jan-04, ahu: created 11-Feb-04, ahu: isolated as a component */ // ***************************************************************************** #include "rcsid.hpp" -EXIV2_RCSID("@(#) $Name: $ $Revision: 1.5 $ $RCSfile: types.cpp,v $") +EXIV2_RCSID("@(#) $Name: $ $Revision: 1.6 $ $RCSfile: types.cpp,v $") // ***************************************************************************** // included header files @@ -232,4 +232,34 @@ namespace Exif { os << std::dec << std::setfill(' '); } // hexdump + int gcd(int a, int b) + { + int temp; + if (a < b) { + temp = a; + a = b; + b = temp; + } + while ((temp = a % b) != 0) { + a = b; + b = temp; + } + return b; + } // gcd + + long lgcd(long a, long b) + { + long temp; + if (a < b) { + temp = a; + a = b; + b = temp; + } + while ((temp = a % b) != 0) { + a = b; + b = temp; + } + return b; + } // lgcd + } // namespace Exif diff --git a/src/types.hpp b/src/types.hpp index 39cf47b0..5f431a12 100644 --- a/src/types.hpp +++ b/src/types.hpp @@ -21,7 +21,7 @@ /*! @file types.hpp @brief Type definitions for Exiv2 and related functionality - @version $Name: $ $Revision: 1.8 $ + @version $Name: $ $Revision: 1.9 $ @author Andreas Huggel (ahu) ahuggel@gmx.net @date 09-Jan-04, ahu: created @@ -195,6 +195,18 @@ namespace Exif { offset. */ void hexdump(std::ostream& os, const char* buf, long len, long offset =0); + + /*! + @brief Return the greatest common denominator of integers a and b. + Both parameters must be greater than 0. + */ + int gcd(int a, int b); + + /*! + @brief Return the greatest common denominator of long values a and b. + Both parameters must be greater than 0. + */ + long lgcd(long a, long b); // ***************************************************************************** // template and inline definitions