File: xxl_max.cc

package info (click to toggle)
abacus 0.9.13-3
  • links: PTS
  • area: main
  • in suites: slink
  • size: 6,308 kB
  • ctags: 5,121
  • sloc: ansic: 27,541; cpp: 11,425; tcl: 7,564; makefile: 386; yacc: 327; lex: 265; sh: 221
file content (64 lines) | stat: -rw-r--r-- 1,488 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// $Id: xxl_max.cc,v 1.3 1997/01/07 01:07:36 aml Exp $

#include "xxl_funcs.hh"
#include "sheet.hh"


Stack_elem *Max::eval(Stack_elem *p,Sheet *sheet, short col, short row) {
    double x;
    Range_iter r(p->contents.rg_val);
    Ref ref;
    Stack_elem *s;

    sheet->propagate_error(p,se);
    switch(p->type) {
      case FORM_FP:
      case FORM_INT:
      case FORM_REF:
      case FORM_STRING:
        x = sheet->stack_value(p);
        max = MAX(x,max);
        se->type = FORM_FP;
        se->contents.fp_val = max;
        return(se);
      case FORM_RANGE:
        short i,j;

        for(r.first(ref); !r.last();  r.next(ref)){
            i = cell_address(ref.col,col);
            j = cell_address(ref.row,row);
            s = sheet->cellRef(i,j);
            sheet->propagate_error(s,se);
            x = sheet->stack_value(s);
            max = MAX(x,max);
        }
        se->type = FORM_FP;
        se->contents.fp_val = max;
        return(se);
      default:
        internal_error();
    }
}

Max::Max() {
    max = -1.0e30; /* AML */
    se = new Stack_elem;
}

Max::~Max() {
    delete se;
}

// $Log: xxl_max.cc,v $
// Revision 1.3  1997/01/07  01:07:36  aml
// Error propagation for formulas fixed.
// Edit operations in place.
//
// Revision 1.2  1996/12/11  21:39:48  aml
// Sumif implemented.
// Diverse time functions implemented.
// Fixed needtoscroll2 to avoid out of control scroll.
//
// Revision 1.1  1996/03/08 12:49:05  aml
// Initial revision
//