template.c

MudOSa4DGD/mudlib/dgd/lib/sys/efun/template.c · 611 B

From the archive MudOSa4DGD-30.06.98.tar.gz

Download the archive   « Back to the archive contents

/*
 * template.c
 *
 * Small template-alike functions that are implemented as functions
 *
 * (C) Frank Schmidt, Jesus@NorseMUD
 *
 */


/* return absolute value */
static mixed abs(mixed num) {
#if 0
  switch (typeof(num)) {
  case T_INT: return (num < 0 ? -num : num);
  case T_FLOAT: return (num < 0.0 ? -num : num);
  default:
    error("Wrong type of argument 1 to function abs()");
    break;
  }
#else
  return num < 0 ? -num : num;
#endif
}

static mixed min(mixed a, mixed b) {
  if (a <= b) return a;
  else return b;
}

static mixed max(mixed a, mixed b) {
  if (a >= b) return a;
  else return b;
}

Site Stats

Snippets: 1791
Codebases: 571