libtrbase  1.0.2
Web server and task management solution.
math.c File Reference
#include "tr/math.h"
+ Include dependency graph for math.c:

Go to the source code of this file.

Functions

long TR_euklidGcd (register long val1, register long val2)
 
long TR_lcm (register long val1, register long val2)
 

Detailed Description

Common reusable definitions.

Todo:
All public symbols need to be prefixed to make name clashes more unlikely.
Author
Georg Hopp

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Definition in file math.c.

Function Documentation

long TR_euklidGcd ( register long  val1,
register long  val2 
)

Definition at line 30 of file math.c.

References SWAP_XOR.

Referenced by TR_lcm().

31 {
32  register long mod;
33 
34  if(val2 > val1) SWAP_XOR(val1, val2);
35 
36  mod = val1 % val2;
37  while (mod != 0) {
38  val1 = val2;
39  val2 = mod;
40  mod = val1 % val2;
41  }
42 
43  return val2;
44 }
#define SWAP_XOR(a, b)
Definition: commons.h:52

+ Here is the caller graph for this function:

long TR_lcm ( register long  val1,
register long  val2 
)

Definition at line 47 of file math.c.

References TR_euklidGcd().

48 {
49  return val1 * val2 / TR_euklidGcd(val1, val2);
50 }
long TR_euklidGcd(register long val1, register long val2)
Definition: math.c:30

+ Here is the call graph for this function: