pike.git / src / operators.c

version» Context lines:

pike.git/src/operators.c:1:   /*\   ||| This file a part of Pike, and is copyright by Fredrik Hubinette   ||| Pike is distributed as GPL (General Public License)   ||| See the files COPYING and DISCLAIMER for more information.   \*/   #include <math.h>   #include "global.h" - RCSID("$Id: operators.c,v 1.13 1997/04/16 03:09:15 hubbe Exp $"); + RCSID("$Id: operators.c,v 1.14 1997/04/28 23:48:42 hubbe Exp $");   #include "interpret.h"   #include "svalue.h"   #include "multiset.h"   #include "mapping.h"   #include "array.h"   #include "stralloc.h"   #include "opcodes.h"   #include "operators.h"   #include "language.h"   #include "memory.h"
pike.git/src/operators.c:984:    }       case T_FLOAT:    if(sp[-1].u.float_number == 0.0)    error("Division by zero.\n");    sp--;    sp[-1].u.float_number /= sp[0].u.float_number;    return;       case T_INT: +  { +  INT32 tmp;    if (sp[-1].u.integer == 0)    error("Division by zero\n");    sp--; -  sp[-1].u.integer /= sp[0].u.integer; +  +  tmp=sp[-1].u.integer / sp[0].u.integer; +  if(tmp<0) +  if(tmp * sp[0].u.integer > sp[-1].u.integer) +  tmp--; +  sp[-1].u.integer=tmp;    return; -  +  }       default:    error("Bad argument 1 to divide.\n");    }   }      void f_divide(INT32 args)   {    if(args != 2)    error("Bad number of args to `/\n");
pike.git/src/operators.c:1040:    error("Modulo by zero.\n");    sp--;    foo=sp[-1].u.float_number / sp[0].u.float_number;    foo=sp[-1].u.float_number - sp[0].u.float_number * floor(foo);    sp[-1].u.float_number=foo;    return;    }    case T_INT:    if (sp[-1].u.integer == 0) error("Modulo by zero.\n");    sp--; +  if(sp[-1].u.integer>=0) +  { +  if(sp[0].u.integer>=0) +  {    sp[-1].u.integer %= sp[0].u.integer; -  +  }else{ +  sp[-1].u.integer=sp[0].u.integer+(sp[-1].u.integer % -sp[0].u.integer); +  } +  }else{ +  if(sp[0].u.integer>=0) +  { +  sp[-1].u.integer=sp[0].u.integer-(-sp[-1].u.integer % sp[0].u.integer); +  }else{ +  sp[-1].u.integer=-(-sp[-1].u.integer % -sp[0].u.integer); +  } +  }    return;       default:    error("Bad argument 1 to modulo.\n");    }   }      void f_mod(INT32 args)   {    if(args != 2)