Project

General

Profile

« Previous | Next » 

Revision 239f4429

Added by Bourbouh over 3 years ago

fix rem and mod

View differences:

include/simulink_math_fcn.c
19 19
}
20 20

  
21 21
double rem_real (double x, double y) {
22
  return fmod(x, y);
22
    if (x == 0.0 || y == 0.0){
23
        return 0.0;
24
    }else{
25
        return fmod(x, y);
26
    }
23 27
}
24 28

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

Also available in: Unified diff