added CEIL and FLOOR
This commit is contained in:
@@ -58,6 +58,8 @@
|
||||
* .22 03-15-91 mrk moved code from calcRecord to here
|
||||
* .23 08-01-91 rac don't use FETCH_G ... for V2
|
||||
* .24 02-20-92 rcz fixed for vxWorks build
|
||||
* .25 02-24-92 jba add EXP and fix for EXPON when *pstacktop is 0
|
||||
* .26 02-28-92 jba added CEIL and FLOOR
|
||||
*/
|
||||
|
||||
/* This module contains the code for processing the arithmetic
|
||||
@@ -107,7 +109,6 @@ char *post;
|
||||
{
|
||||
double *pstacktop; /* stack of values */
|
||||
double stack[80];
|
||||
double temp;
|
||||
short temp1;
|
||||
short i;
|
||||
double *top;
|
||||
@@ -258,6 +259,10 @@ char *post;
|
||||
*pstacktop = sqrt(*pstacktop);
|
||||
break;
|
||||
|
||||
case EXP:
|
||||
*pstacktop = exp(*pstacktop);
|
||||
break;
|
||||
|
||||
case LOG_10:
|
||||
*pstacktop = log10(*pstacktop);
|
||||
break;
|
||||
@@ -273,6 +278,7 @@ char *post;
|
||||
|
||||
case EXPON:
|
||||
--pstacktop;
|
||||
if (*pstacktop == 0) break;
|
||||
if (*pstacktop < 0){
|
||||
temp1 = (int) *(pstacktop+1);
|
||||
/* is exponent an integer */
|
||||
@@ -409,6 +415,14 @@ char *post;
|
||||
*pstacktop = tanh(*pstacktop);
|
||||
break;
|
||||
|
||||
case CEIL:
|
||||
*pstacktop = ceil(*pstacktop);
|
||||
break;
|
||||
|
||||
case FLOOR:
|
||||
*pstacktop = floor(*pstacktop);
|
||||
break;
|
||||
|
||||
case REL_NOT:
|
||||
*pstacktop = ((*pstacktop)?0:1);
|
||||
break;
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
* element table and added a warning label
|
||||
* .05 11-26-90 lrd fix SINH, COSH, TANH
|
||||
* .06 02-20-92 rcz fixed for vxWorks build
|
||||
* .07 02-24-92 jba add EXP and fixed trailing blanks in expression
|
||||
*/
|
||||
|
||||
/*
|
||||
@@ -139,11 +140,14 @@ static struct expression_element elements[] = {
|
||||
"ABS", 7, 8, UNARY_OPERATOR, ABS_VAL, /* absolute value */
|
||||
"NOT", 7, 8, UNARY_OPERATOR, UNARY_NEG, /* unary negate */
|
||||
"SQR", 7, 8, UNARY_OPERATOR, SQU_RT, /* square root */
|
||||
"EXP", 7, 8, UNARY_OPERATOR, EXP, /* exponential function */
|
||||
"LOGE", 7, 8, UNARY_OPERATOR, LOG_E, /* log E */
|
||||
"LOG", 7, 8, UNARY_OPERATOR, LOG_10, /* log 10 */
|
||||
"ACOS", 7, 8, UNARY_OPERATOR, ACOS, /* arc cosine */
|
||||
"ASIN", 7, 8, UNARY_OPERATOR, ASIN, /* arc sine */
|
||||
"ATAN", 7, 8, UNARY_OPERATOR, ATAN, /* arc tangent */
|
||||
"CEIL", 7, 8, UNARY_OPERATOR, CEIL, /* smallest integer >= */
|
||||
"FLOOR", 7, 8, UNARY_OPERATOR, FLOOR, /* largest integer <= */
|
||||
"COSH", 7, 8, UNARY_OPERATOR, COSH, /* hyperbolic cosine */
|
||||
"COS", 7, 8, UNARY_OPERATOR, COS, /* cosine */
|
||||
"SINH", 7, 8, UNARY_OPERATOR, SINH, /* hyperbolic sine */
|
||||
@@ -211,7 +215,7 @@ static struct expression_element elements[] = {
|
||||
*
|
||||
* find the pointer to an entry in the element table
|
||||
*/
|
||||
static find_element(pbuffer,pelement,pno_bytes)
|
||||
static int find_element(pbuffer,pelement,pno_bytes)
|
||||
register char *pbuffer;
|
||||
register struct expression_element **pelement;
|
||||
register short *pno_bytes;
|
||||
@@ -235,14 +239,12 @@ static find_element(pbuffer,pelement,pno_bytes)
|
||||
*
|
||||
* get an expression element
|
||||
*/
|
||||
static get_element(pinfix,pelement,pno_bytes,plink)
|
||||
static int get_element(pinfix,pelement,pno_bytes,plink)
|
||||
register char *pinfix;
|
||||
register struct expression_element **pelement;
|
||||
register short *pno_bytes;
|
||||
struct link *plink;
|
||||
{
|
||||
char buffer[40];
|
||||
register short i;
|
||||
|
||||
/* get the next expression element from the infix expression */
|
||||
if (*pinfix == NULL) return(END);
|
||||
@@ -251,6 +253,7 @@ struct link *plink;
|
||||
*pno_bytes += 1;
|
||||
pinfix++;
|
||||
}
|
||||
if (*pinfix == NULL) return(END);
|
||||
if (!find_element(pinfix,pelement,pno_bytes))
|
||||
return(UNKNOWN_ELEMENT);
|
||||
return(FINE);
|
||||
@@ -273,7 +276,6 @@ short *perror;
|
||||
short no_bytes;
|
||||
register short operand_needed;
|
||||
register short new_expression;
|
||||
register short link_inx; /* index into variable table */
|
||||
struct link new_link;
|
||||
struct expression_element stack[80];
|
||||
struct expression_element *pelement;
|
||||
|
||||
@@ -58,6 +58,8 @@
|
||||
* .22 03-15-91 mrk moved code from calcRecord to here
|
||||
* .23 08-01-91 rac don't use FETCH_G ... for V2
|
||||
* .24 02-20-92 rcz fixed for vxWorks build
|
||||
* .25 02-24-92 jba add EXP and fix for EXPON when *pstacktop is 0
|
||||
* .26 02-28-92 jba added CEIL and FLOOR
|
||||
*/
|
||||
|
||||
/* This module contains the code for processing the arithmetic
|
||||
@@ -107,7 +109,6 @@ char *post;
|
||||
{
|
||||
double *pstacktop; /* stack of values */
|
||||
double stack[80];
|
||||
double temp;
|
||||
short temp1;
|
||||
short i;
|
||||
double *top;
|
||||
@@ -258,6 +259,10 @@ char *post;
|
||||
*pstacktop = sqrt(*pstacktop);
|
||||
break;
|
||||
|
||||
case EXP:
|
||||
*pstacktop = exp(*pstacktop);
|
||||
break;
|
||||
|
||||
case LOG_10:
|
||||
*pstacktop = log10(*pstacktop);
|
||||
break;
|
||||
@@ -273,6 +278,7 @@ char *post;
|
||||
|
||||
case EXPON:
|
||||
--pstacktop;
|
||||
if (*pstacktop == 0) break;
|
||||
if (*pstacktop < 0){
|
||||
temp1 = (int) *(pstacktop+1);
|
||||
/* is exponent an integer */
|
||||
@@ -409,6 +415,14 @@ char *post;
|
||||
*pstacktop = tanh(*pstacktop);
|
||||
break;
|
||||
|
||||
case CEIL:
|
||||
*pstacktop = ceil(*pstacktop);
|
||||
break;
|
||||
|
||||
case FLOOR:
|
||||
*pstacktop = floor(*pstacktop);
|
||||
break;
|
||||
|
||||
case REL_NOT:
|
||||
*pstacktop = ((*pstacktop)?0:1);
|
||||
break;
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
* -----------------
|
||||
* .01 01-11-89 lrd add right and left shift
|
||||
* .02 02-01-89 lrd add trig functions
|
||||
* .03 02-17-92 jba add exp
|
||||
*/
|
||||
|
||||
/* defines for element table */
|
||||
@@ -72,27 +73,30 @@
|
||||
#define ABS_VAL 37
|
||||
#define UNARY_NEG 38
|
||||
#define SQU_RT 39
|
||||
#define LOG_10 40
|
||||
#define LOG_E 41
|
||||
#define RANDOM 42
|
||||
#define ADD 43
|
||||
#define SUB 44
|
||||
#define MULT 45
|
||||
#define DIV 46
|
||||
#define EXPON 47
|
||||
#define MODULO 48
|
||||
#define BIT_OR 49
|
||||
#define BIT_AND 50
|
||||
#define BIT_EXCL_OR 51
|
||||
#define GR_OR_EQ 52
|
||||
#define GR_THAN 53
|
||||
#define LESS_OR_EQ 54
|
||||
#define LESS_THAN 55
|
||||
#define NOT_EQ 56
|
||||
#define EQUAL 57
|
||||
#define REL_OR 58
|
||||
#define REL_AND 59
|
||||
#define REL_NOT 60
|
||||
#define BIT_NOT 61
|
||||
#define PAREN 62
|
||||
#define EXP 40
|
||||
#define CEIL 41
|
||||
#define FLOOR 42
|
||||
#define LOG_10 43
|
||||
#define LOG_E 44
|
||||
#define RANDOM 45
|
||||
#define ADD 46
|
||||
#define SUB 47
|
||||
#define MULT 48
|
||||
#define DIV 49
|
||||
#define EXPON 50
|
||||
#define MODULO 51
|
||||
#define BIT_OR 52
|
||||
#define BIT_AND 53
|
||||
#define BIT_EXCL_OR 54
|
||||
#define GR_OR_EQ 55
|
||||
#define GR_THAN 56
|
||||
#define LESS_OR_EQ 57
|
||||
#define LESS_THAN 58
|
||||
#define NOT_EQ 59
|
||||
#define EQUAL 60
|
||||
#define REL_OR 61
|
||||
#define REL_AND 62
|
||||
#define REL_NOT 63
|
||||
#define BIT_NOT 64
|
||||
#define PAREN 65
|
||||
#define END_STACK -1
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
* element table and added a warning label
|
||||
* .05 11-26-90 lrd fix SINH, COSH, TANH
|
||||
* .06 02-20-92 rcz fixed for vxWorks build
|
||||
* .07 02-24-92 jba add EXP and fixed trailing blanks in expression
|
||||
*/
|
||||
|
||||
/*
|
||||
@@ -139,11 +140,14 @@ static struct expression_element elements[] = {
|
||||
"ABS", 7, 8, UNARY_OPERATOR, ABS_VAL, /* absolute value */
|
||||
"NOT", 7, 8, UNARY_OPERATOR, UNARY_NEG, /* unary negate */
|
||||
"SQR", 7, 8, UNARY_OPERATOR, SQU_RT, /* square root */
|
||||
"EXP", 7, 8, UNARY_OPERATOR, EXP, /* exponential function */
|
||||
"LOGE", 7, 8, UNARY_OPERATOR, LOG_E, /* log E */
|
||||
"LOG", 7, 8, UNARY_OPERATOR, LOG_10, /* log 10 */
|
||||
"ACOS", 7, 8, UNARY_OPERATOR, ACOS, /* arc cosine */
|
||||
"ASIN", 7, 8, UNARY_OPERATOR, ASIN, /* arc sine */
|
||||
"ATAN", 7, 8, UNARY_OPERATOR, ATAN, /* arc tangent */
|
||||
"CEIL", 7, 8, UNARY_OPERATOR, CEIL, /* smallest integer >= */
|
||||
"FLOOR", 7, 8, UNARY_OPERATOR, FLOOR, /* largest integer <= */
|
||||
"COSH", 7, 8, UNARY_OPERATOR, COSH, /* hyperbolic cosine */
|
||||
"COS", 7, 8, UNARY_OPERATOR, COS, /* cosine */
|
||||
"SINH", 7, 8, UNARY_OPERATOR, SINH, /* hyperbolic sine */
|
||||
@@ -211,7 +215,7 @@ static struct expression_element elements[] = {
|
||||
*
|
||||
* find the pointer to an entry in the element table
|
||||
*/
|
||||
static find_element(pbuffer,pelement,pno_bytes)
|
||||
static int find_element(pbuffer,pelement,pno_bytes)
|
||||
register char *pbuffer;
|
||||
register struct expression_element **pelement;
|
||||
register short *pno_bytes;
|
||||
@@ -235,14 +239,12 @@ static find_element(pbuffer,pelement,pno_bytes)
|
||||
*
|
||||
* get an expression element
|
||||
*/
|
||||
static get_element(pinfix,pelement,pno_bytes,plink)
|
||||
static int get_element(pinfix,pelement,pno_bytes,plink)
|
||||
register char *pinfix;
|
||||
register struct expression_element **pelement;
|
||||
register short *pno_bytes;
|
||||
struct link *plink;
|
||||
{
|
||||
char buffer[40];
|
||||
register short i;
|
||||
|
||||
/* get the next expression element from the infix expression */
|
||||
if (*pinfix == NULL) return(END);
|
||||
@@ -251,6 +253,7 @@ struct link *plink;
|
||||
*pno_bytes += 1;
|
||||
pinfix++;
|
||||
}
|
||||
if (*pinfix == NULL) return(END);
|
||||
if (!find_element(pinfix,pelement,pno_bytes))
|
||||
return(UNKNOWN_ELEMENT);
|
||||
return(FINE);
|
||||
@@ -273,7 +276,6 @@ short *perror;
|
||||
short no_bytes;
|
||||
register short operand_needed;
|
||||
register short new_expression;
|
||||
register short link_inx; /* index into variable table */
|
||||
struct link new_link;
|
||||
struct expression_element stack[80];
|
||||
struct expression_element *pelement;
|
||||
|
||||
Reference in New Issue
Block a user