Project

General

Profile

Statistics
| Branch: | Tag: | Revision:

lustrec / include / simulink_math_fcn.c @ 0bca9d53

History | View | Annotate | Download (511 Bytes)

1
#include "simulink_math_fcn.h"
2
#include <math.h>
3

    
4

    
5
int rem_int (int x, int y) {
6
  return x%y;
7
}
8

    
9
int mod_int (int x, int y) {
10
  int tmp;
11
  if (y == 0) { return x; };
12
  tmp = x%y;
13
  if (y < 0 && tmp > 0) {
14
    return tmp+y;
15
  }
16
  else {
17
    return tmp;
18
  }
19
}
20

    
21
double rem_real (double x, double y) {
22
  return fmod(x, y);
23
}
24

    
25
double mod_real (double x, double y) {
26
  double tmp = 0.;
27
  if (y == 0.) { return x; };
28
  tmp = fmod(x, y);
29
  if (y < 0. && tmp > 0.) {
30
    return tmp+y;
31
  }
32
  else {
33
    return tmp;
34
  }
35
}