pike.git / src / operators.c

version» Context lines:

pike.git/src/operators.c:1693:    sp[-1].u.integer=size;    sp[-1].subtype = NUMBER_NUMBER;   #endif /* AUTO_BIGNUM */    break;       case BIT_FLOAT:    if (args > 2) {    /* Attempt to minimize the accumulated summation error    * by adding the smallest (absolute) values first.    * -  * This can eg happen when the number of values to add -  * is in the same order as the number of bits in the -  * mantissa. +  * Large accumulated errors can occur eg when the number +  * of values to add is of the same order as the largest +  * number representable by the mantissa alone. ie when +  * the sum differs by an order of magnitude from a +  * typical term.    */    /* Heapify */    for(e = args>>1; e--;) {    float_heap_sift_down(Pike_sp-args, e, args);    }    while (args > 2) { -  +  /* Pop the smallest element from the heap. */    FLOAT_ARG_TYPE top = Pike_sp[-args].u.float_number;    Pike_sp[-args] = *(--Pike_sp);    args--;    float_heap_sift_down(Pike_sp-args, 0, args);    -  +  /* And add it to the second smallest. */    Pike_sp[-args].u.float_number += top;    float_heap_sift_down(Pike_sp-args, 0, args);    }    }    sp[-2].u.float_number += sp[-1].u.float_number;    sp--;    break;       case BIT_FLOAT|BIT_INT:    {
pike.git/src/operators.c:2448:   PMOD_EXPORT void f_minus(INT32 args)   {    switch(args)    {    case 0: SIMPLE_TOO_FEW_ARGS_ERROR("`-", 1);    case 1: o_negate(); break;    case 2: o_subtract(); break;    default:    {    INT32 e; +  TYPE_FIELD types = 0;    struct svalue *s=sp-args; -  +  +  for(e=-args;e<0;e++) types|=1<<sp[e].type; +  +  if ((types | BIT_INT | BIT_FLOAT) == (BIT_INT | BIT_FLOAT)) { +  /* Take advantage of the precision control in f_add(). */ +  f_add(args-1); +  o_subtract(); +  break; +  } +     push_svalue(s);    for(e=1;e<args;e++)    {    push_svalue(s+e);    o_subtract();    }    assign_svalue(s,sp-1);    pop_n_elems(sp-s-1);    }    }