Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-21 10:05:32

0001 /*
0002  *  qp_exe_op_num.h  --
0003  *  Template for the simple numeric operations.
0004  *  
0005  *  Original: 20-Jan-1995 16:57
0006  *
0007  *  Author:   Maarten Ballintijn <Maarten.Ballintijn@cern.ch>
0008  *
0009  *  $Id$
0010  *
0011  *  $Log$
0012  *  Revision 1.4  1996/04/23 18:38:33  maartenb
0013  *  - Add RCS keywords
0014  *
0015  *
0016  */
0017 
0018 case FC_PLUS + (OP_BASE):
0019     o1 = &stack[frame[framep]];
0020     o2 = &stack[frame[framep-1]];
0021     POP_FRAME(1);
0022     *((OP_TYPE *) o2) = *((OP_TYPE *) o1) + *((OP_TYPE *) o2);
0023     break;
0024 
0025 case FC_MINUS + (OP_BASE):
0026     o1 = &stack[frame[framep]];
0027     o2 = &stack[frame[framep-1]];
0028     POP_FRAME(1);
0029     *((OP_TYPE *) o2) = *((OP_TYPE *) o1) - *((OP_TYPE *) o2);
0030     break;
0031 
0032 case FC_TIMES + (OP_BASE):
0033     o1 = &stack[frame[framep]];
0034     o2 = &stack[frame[framep-1]];
0035     POP_FRAME(1);
0036     *((OP_TYPE *) o2) = *((OP_TYPE *) o1) * *((OP_TYPE *) o2);
0037     break;
0038 
0039 case FC_DIV + (OP_BASE):
0040     o1 = &stack[frame[framep]];
0041     o2 = &stack[frame[framep-1]];
0042     POP_FRAME(1);
0043     if ( *((OP_TYPE *) o2) == 0 ) {
0044         sf_report( "Divide by zero\n" );
0045         *errp = R_MATH_ERROR;
0046         running = FALSE;
0047         *((OP_TYPE *) o2) = 0;
0048     } else {
0049         *((OP_TYPE *) o2) = *((OP_TYPE *) o1) / *((OP_TYPE *) o2);
0050     }
0051     break;
0052 
0053 case FC_POW + (OP_BASE):
0054     o1 = &stack[frame[framep]];
0055     o2 = &stack[frame[framep-1]];
0056     POP_FRAME(1);
0057     {
0058         double      x = *((OP_TYPE *) o1);
0059         double      y = *((OP_TYPE *) o2);
0060         double      dummy;
0061 
0062         if ( ( x == 0. && y <= 0. ) || ( x < 0. &&  modf(y,&dummy) != 0.  ) ) {
0063             sf_report( "Illegal values for power: %lg**%lg\n", x, y );
0064             *errp = R_MATH_ERROR;
0065             running = FALSE;
0066             *((OP_TYPE *) o2) = 0;
0067         } else {
0068             *((OP_TYPE *) o2) = pow( x, y );
0069         }
0070     }
0071     break;
0072 
0073 case FC_UMINUS + (OP_BASE):     /* assume that signed and unsigned */
0074     o1 = &stack[frame[framep]]; /* have the same aligment ... */
0075     SET_FRAME_TYPE( datatype_signed[ OP_DTYPE ] );
0076     *((OP_TYPE *) o1) = - *((OP_TYPE *) o1);
0077     break;
0078 
0079 case FC_MIN + (OP_BASE):
0080     o1 = &stack[frame[framep]];
0081     o2 = &stack[frame[framep-1]];
0082     POP_FRAME(1);
0083     if ( *((OP_TYPE *) o1) < *((OP_TYPE *) o2) ) {
0084         *((OP_TYPE *) o2) = *((OP_TYPE *) o1);
0085     }
0086     break;
0087 
0088 case FC_MAX + (OP_BASE):
0089     o1 = &stack[frame[framep]];
0090     o2 = &stack[frame[framep-1]];
0091     POP_FRAME(1);
0092     if ( *((OP_TYPE *) o1) > *((OP_TYPE *) o2) ) {
0093         *((OP_TYPE *) o2) = *((OP_TYPE *) o1);
0094     }
0095     break;