G:/ScriptBasic/source/commands/mathops.c File Reference

#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <limits.h>
#include "../command.h"

Go to the source code of this file.

Defines

#define RAISEMATHERROR   "raisematherror"
#define LOGOP(NAME, OP)
#define NOCOMMAND(XXX)
#define LONGOP(NAME, OP)

Functions

static int STRCMP (pExecuteObject pEo, VARIABLE Op1, VARIABLE Op2, int iCase)
static long longpow (long a, long b)
static double doublepow (double a, long b)
long * RaiseError (pExecuteObject pEo)
 if (!ISINTEGER(Op1)||!ISINTEGER(Op2))
 if (0==lop1)
 if (lResult/lop1==lop2)
 RETURN_DOUBLE_VALUE_OR_LONG (GETDOUBLEVALUE(Op1)*GETDOUBLEVALUE(Op2))
 if (memory_IsUndef(Op1)||memory_IsUndef(Op2))
 if (TYPE(Op1)==VTYPE_STRING||TYPE(Op2)==VTYPE_STRING)
 RETURN_LONG_VALUE (GETLONGVALUE(Op1)==GETLONGVALUE(Op2)?-1L:0L)
 RETURN_LONG_VALUE (GETLONGVALUE(Op1)!=GETLONGVALUE(Op2)?-1L:0L)
 if (nItem)
 if (ISINTEGER(Op1))
 RETURN_DOUBLE_VALUE_OR_LONG (GETLONGVALUE(Op1))
 if (!ISINTEGER(Op1))
 RETURN_LONG_VALUE (-GETLONGVALUE(Op1)) ENDNODE nItem
 RETURN_LONG_VALUE (~GETLONGVALUE(Op1)) ENDNODE nItem
 if (memory_IsUndef(vMantissa))
 if (memory_IsUndef(vExponent))
 if (bExpIsInt)
 if (lop2==0)
 RETURN_LONG_VALUE (((long)(lop1/lop2)))
 if (lop1%lop2)

Variables

NODE nItem
VARIABLE Op1
VARIABLE Op2
double dResult
long lResult
long lop1
long lop2
 USE_CALLER_MORTALS
 nItem = PARAMETERLIST
 Op1 = EVALUATEEXPRESSION(CAR(nItem))
 nItem = CDR(nItem)
 Op2 = EVALUATEEXPRESSION(CAR(nItem))
 lop1 = GETLONGVALUE(Op1)
 lop2 = GETLONGVALUE(Op2)
 lResult = lop1 * lop2
END NODE nItem
VARIABLE Op1
VARIABLE Op2
double dResult
long lResult
long lop1
long lop2
 USE_CALLER_MORTALS
 nItem = PARAMETERLIST
 Op1 = EVALUATEEXPRESSION(CAR(nItem))
 nItem = CDR(nItem)
VARIABLE Op1
 USE_CALLER_MORTALS
 nItem = PARAMETERLIST
 Op1 = EVALUATEEXPRESSION(CAR(nItem))
VARIABLE vMantissa
VARIABLE vExponent
double dMantissa
double dExponent
double dRoot
double dResult
long lMantissa
long lExponent
long lRoot
int bMantIsInt
int bExpIsInt
 USE_CALLER_MORTALS
 nItem = PARAMETERLIST
 vMantissa = EVALUATEEXPRESSION(CAR(nItem))
 ASSERTOKE
 nItem = CDR(nItem)
 vExponent = EVALUATEEXPRESSION(CAR(nItem))
 ASSERTOKE
 bMantIsInt = ISINTEGER(vMantissa)
 bExpIsInt = ISINTEGER(vExponent)
VARIABLE Op1
VARIABLE Op2
double dop1
double dop2
long lop1
long lop2
 USE_CALLER_MORTALS
 nItem = PARAMETERLIST
 Op1 = EVALUATEEXPRESSION(CAR(nItem))
 nItem = CDR(nItem)
 Op2 = EVALUATEEXPRESSION(CAR(nItem))
 lop1 = GETLONGVALUE(Op1)
 lop2 = GETLONGVALUE(Op2)
 lop1 = GETLONGVALUE(Op1)
 lop2 = GETLONGVALUE(Op2)
END VARIABLE Op1
 USE_CALLER_MORTALS
 Op1 = EVALUATEEXPRESSION(CAR(PARAMETERLIST))
 ASSERTOKE
 RESULT = Op1


Define Documentation

#define LOGOP NAME,
OP   ) 
 

Referenced by RETURN_LONG_VALUE().

#define LONGOP NAME,
OP   ) 
 

Value:

COMMAND(NAME)\
  NODE nItem;\
  VARIABLE Op1,Op2;\
  USE_CALLER_MORTALS;\
  nItem = PARAMETERLIST;\
  Op1 = EVALUATEEXPRESSION(CAR(nItem));\
  NONULOP(Op1)\
  nItem = CDR(nItem);\
  Op2 = EVALUATEEXPRESSION(CAR(nItem));\
  NONULOP(Op2)\
  RETURN_LONG_VALUE( GETLONGVALUE(Op1) OP GETLONGVALUE(Op2) )\
END

Referenced by RETURN_LONG_VALUE().

#define NOCOMMAND XXX   ) 
 

Value:

COMMAND(XXX)\
NOTIMPLEMENTED;\
END

#define RAISEMATHERROR   "raisematherror"
 

Definition at line 84 of file mathops.c.

Referenced by RaiseError().


Function Documentation

static double doublepow double  a,
long  b
[static]
 

Definition at line 72 of file mathops.c.

References result.

Referenced by if().

if lop1 lop2  ) 
 

Definition at line 868 of file mathops.c.

References RETURN_DOUBLE_VALUE().

if lop2  = = 0  ) 
 

Definition at line 813 of file mathops.c.

if bExpIsInt   ) 
 

Definition at line 672 of file mathops.c.

References doublepow(), longpow(), NULL, RESULT, RETURN, RETURN_DOUBLE_VALUE(), and RETURN_LONG_VALUE().

if memory_IsUndef(vExponent  ) 
 

Definition at line 664 of file mathops.c.

References NULL, RESULT, and RETURN.

if memory_IsUndef(vMantissa  ) 
 

Definition at line 656 of file mathops.c.

References NULL, RESULT, and RETURN.

if ISINTEGER(Op1)  ) 
 

Definition at line 584 of file mathops.c.

References RETURN_DOUBLE_VALUE_OR_LONG().

if ISINTEGER(Op1  ) 
 

Definition at line 514 of file mathops.c.

References RETURN_LONG_VALUE().

if nItem   ) 
 

Definition at line 472 of file mathops.c.

References RETURN_DOUBLE_VALUE_OR_LONG(), and RETURN_LONG_VALUE().

if TYPE(Op1 = = VTYPE_STRING || TYPE(Op2) == VTYPE_STRING  ) 
 

Definition at line 185 of file mathops.c.

References pEo, RETURN_LONG_VALUE(), and STRCMP().

if memory_IsUndef(Op1)||memory_IsUndef(Op2  ) 
 

Definition at line 180 of file mathops.c.

References RETURN_LONG_VALUE().

if lResult lop1 = lop2  ) 
 

Definition at line 146 of file mathops.c.

References RETURN_LONG_VALUE().

if = lop1  ) 
 

Definition at line 143 of file mathops.c.

References RETURN_LONG_VALUE().

if ISINTEGER(Op1)||!ISINTEGER(Op2)  ) 
 

Definition at line 137 of file mathops.c.

References RETURN_DOUBLE_VALUE_OR_LONG().

static long longpow long  a,
long  b
[static]
 

Definition at line 60 of file mathops.c.

References result.

Referenced by if().

long* RaiseError pExecuteObject  pEo  ) 
 

Definition at line 85 of file mathops.c.

References NULL, options_GetR(), options_Set(), and RAISEMATHERROR.

RETURN_DOUBLE_VALUE_OR_LONG GETLONGVALUE(Op1  ) 
 

Definition at line 517 of file mathops.c.

RETURN_DOUBLE_VALUE_OR_LONG GETDOUBLEVALUE(Op1)*GETDOUBLEVALUE(Op2  ) 
 

Definition at line 149 of file mathops.c.

RETURN_LONG_VALUE ((long)(lop1/lop2))   ) 
 

Definition at line 817 of file mathops.c.

RETURN_LONG_VALUE GETLONGVALUE(Op1)  ) 
 

RETURN_LONG_VALUE GETLONGVALUE(Op1)  ) 
 

RETURN_LONG_VALUE GETLONGVALUE(Op1)!  = GETLONGVALUE(Op2) ? -1L : 0L  ) 
 

Definition at line 243 of file mathops.c.

References LOGOP, and LONGOP.

RETURN_LONG_VALUE GETLONGVALUE(Op1 = = GETLONGVALUE(Op2) ? -1L : 0L  ) 
 

Definition at line 196 of file mathops.c.

Referenced by if(), and RETURN_DOUBLE_VALUE().

static int STRCMP pExecuteObject  pEo,
VARIABLE  Op1,
VARIABLE  Op2,
int  iCase
[static]
 

Definition at line 31 of file mathops.c.

References memory_IsUndef(), STRINGVALUE(), and STRLEN().

Referenced by execute_LeftValueSarray(), and if().


Variable Documentation

ASSERTOKE
 

Definition at line 909 of file mathops.c.

ASSERTOKE
 

Definition at line 663 of file mathops.c.

ASSERTOKE
 

Definition at line 655 of file mathops.c.

bExpIsInt = ISINTEGER(vExponent)
 

Definition at line 670 of file mathops.c.

int bExpIsInt
 

Definition at line 647 of file mathops.c.

bMantIsInt = ISINTEGER(vMantissa)
 

Definition at line 669 of file mathops.c.

int bMantIsInt
 

Definition at line 647 of file mathops.c.

double dExponent
 

Definition at line 645 of file mathops.c.

double dMantissa
 

Definition at line 645 of file mathops.c.

double dop1
 

Definition at line 784 of file mathops.c.

double dop2
 

Definition at line 784 of file mathops.c.

double dResult
 

Definition at line 645 of file mathops.c.

double dResult
 

Definition at line 459 of file mathops.c.

double dResult
 

Definition at line 121 of file mathops.c.

double dRoot
 

Definition at line 645 of file mathops.c.

long lExponent
 

Definition at line 646 of file mathops.c.

long lMantissa
 

Definition at line 646 of file mathops.c.

lop1 = GETLONGVALUE(Op1)
 

Definition at line 863 of file mathops.c.

lop1 = GETLONGVALUE(Op1)
 

Definition at line 810 of file mathops.c.

long lop1
 

Definition at line 785 of file mathops.c.

long lop1
 

Definition at line 460 of file mathops.c.

lop1 = GETLONGVALUE(Op1)
 

Definition at line 140 of file mathops.c.

long lop1
 

Definition at line 122 of file mathops.c.

lop2 = GETLONGVALUE(Op2)
 

Definition at line 864 of file mathops.c.

lop2 = GETLONGVALUE(Op2)
 

Definition at line 811 of file mathops.c.

long lop2
 

Definition at line 785 of file mathops.c.

long lop2
 

Definition at line 460 of file mathops.c.

lop2 = GETLONGVALUE(Op2)
 

Definition at line 141 of file mathops.c.

long lop2
 

Definition at line 122 of file mathops.c.

long lResult
 

Definition at line 460 of file mathops.c.

lResult = lop1 * lop2
 

Definition at line 142 of file mathops.c.

long lResult
 

Definition at line 122 of file mathops.c.

long lRoot
 

Definition at line 646 of file mathops.c.

nItem = CDR(nItem)
 

Definition at line 795 of file mathops.c.

nItem = PARAMETERLIST
 

Definition at line 791 of file mathops.c.

nItem = CDR(nItem)
 

Definition at line 661 of file mathops.c.

nItem = PARAMETERLIST
 

Definition at line 653 of file mathops.c.

nItem = PARAMETERLIST
 

Definition at line 614 of file mathops.c.

nItem = CDR(nItem)
 

Definition at line 470 of file mathops.c.

nItem = PARAMETERLIST
 

Definition at line 466 of file mathops.c.

END NODE nItem
 

Definition at line 457 of file mathops.c.

nItem = CDR(nItem)
 

Definition at line 132 of file mathops.c.

nItem = PARAMETERLIST
 

Definition at line 128 of file mathops.c.

NODE nItem
 

Definition at line 119 of file mathops.c.

Op1 = EVALUATEEXPRESSION(CAR(PARAMETERLIST))
 

Definition at line 908 of file mathops.c.

END VARIABLE Op1
 

Definition at line 902 of file mathops.c.

Op1 = EVALUATEEXPRESSION(CAR(nItem))
 

Definition at line 792 of file mathops.c.

VARIABLE Op1
 

Definition at line 782 of file mathops.c.

Op1 = EVALUATEEXPRESSION(CAR(nItem))
 

Definition at line 615 of file mathops.c.

VARIABLE Op1
 

Definition at line 608 of file mathops.c.

Op1 = EVALUATEEXPRESSION(CAR(nItem))
 

Definition at line 467 of file mathops.c.

VARIABLE Op1
 

Definition at line 458 of file mathops.c.

Op1 = EVALUATEEXPRESSION(CAR(nItem))
 

Definition at line 129 of file mathops.c.

VARIABLE Op1
 

Definition at line 120 of file mathops.c.

Op2 = EVALUATEEXPRESSION(CAR(nItem))
 

Definition at line 796 of file mathops.c.

VARIABLE Op2
 

Definition at line 782 of file mathops.c.

VARIABLE Op2
 

Definition at line 458 of file mathops.c.

Op2 = EVALUATEEXPRESSION(CAR(nItem))
 

Definition at line 133 of file mathops.c.

VARIABLE Op2
 

Definition at line 120 of file mathops.c.

RESULT = Op1
 

Definition at line 911 of file mathops.c.

USE_CALLER_MORTALS
 

Definition at line 905 of file mathops.c.

USE_CALLER_MORTALS
 

Definition at line 788 of file mathops.c.

USE_CALLER_MORTALS
 

Definition at line 650 of file mathops.c.

USE_CALLER_MORTALS
 

Definition at line 611 of file mathops.c.

USE_CALLER_MORTALS
 

Definition at line 463 of file mathops.c.

USE_CALLER_MORTALS
 

Definition at line 125 of file mathops.c.

vExponent = EVALUATEEXPRESSION(CAR(nItem))
 

Definition at line 662 of file mathops.c.

VARIABLE vExponent
 

Definition at line 644 of file mathops.c.

vMantissa = EVALUATEEXPRESSION(CAR(nItem))
 

Definition at line 654 of file mathops.c.

VARIABLE vMantissa
 

Definition at line 644 of file mathops.c.


Generated on Sun Mar 12 23:56:33 2006 for ScriptBasic by  doxygen 1.4.6-NO