next up previous
Next: Preprocessor directives Up: dcomment A General Purpose Previous: Comments

Mathematical Operations Allowed in Input File

Mathematical operations of addition(+), subtraction(-), and multiplication(*) are allowed in the input file line. Division(/) is not allowed since it can not be differentiated from the LCS end of line delimiter (/).

Parenthesis are NOT allowed. Operations are evaluated from left to right, with multiplication being performed, then addition/subtraction.

/* math_test.inp */
1+2+3+4 = 10 
1-2+3-4 = -2
2*3-4*6 = -18
6*5.01 = 30.06
4*6+5.01 = 29.01    /* (4*6) + 5.01 = 29.01*/
3-4*6+5.01 = -15.99 /* 3 - (4*6) + 5.01 = -15.99 */
2*3-4*6+5.01 = -12.99  /* (2*3) - (4*6) +5.01 = -12.99 */
/* You can use defines (see section below) in math operations */
#define PI 3.14159265
#define RADIUS 2.0
#define AREA PI*RADIUS*RADIUS
A Circle of radius RADIUS has an area of AREA
evaluates to
10.000000 = 10 
-2.000000 = -2
-18.000000 = -18
30.060000 = 30.06
29.010000 = 29.01    
-15.990000 = -15.99 
-12.990000 = -12.99  
A Circle of radius 2.0 has an area of 12.566371



Jeff Siebers X88554
Mon Apr 21 09:12:07 PDT 1997