1: #include "../h/rt.h"
   2: 
   3: /*
   4:  * abs(x) - absolute value of x.
   5:  */
   6: Xabs(nargs, arg1, arg0)
   7: int nargs;
   8: struct descrip arg1, arg0;
   9:    {
  10:    union numeric result;
  11: 
  12:    switch (cvnum(&arg1, &result)) {
  13:       /*
  14:        * If x is convertible to a numeric, turn arg0 into
  15:        *  a descriptor for the appropriate type and value.  If the
  16:        *  conversion fails, produce an error.  This code assumes that
  17:        *  x = -x is always valid, but this assumption does not always
  18:        *  hold.
  19:        */
  20:       case T_LONGINT:
  21:          if (result.integer < 0L)
  22:             result.integer = -result.integer;
  23:          mkint(result.integer, &arg0);
  24:          break;
  25: 
  26:       case T_REAL:
  27:          if (result.real < 0.0)
  28:             result.real = -result.real;
  29:          mkreal(result.real, &arg0);
  30:          break;
  31: 
  32:       default:
  33:          runerr(102, &arg1);
  34:       }
  35:    }
  36: 
  37: Procblock(abs,1)

Defined functions

Xabs defined in line 6; never used
Last modified: 1984-11-18
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 621
Valid CSS Valid XHTML 1.0 Strict