### Writing Dicom Expression

Dicom expression may be dimensional or dimension-less. You can intuitively write an expression, not so complicated, without knowing any rule.

For example: "1+2*3/4" is a simple dimension-less expression, and "3ft.+1m." is a simple dimensional expression.

Precedence and Associativity rule in Dicom is similar to C/C++ or any other programming language statement. In fact Dicom's operators are a subset of C++ language operators. Some of the functions of Dicom also behave like C/C++ functions.

Apart from the common operators like +, -, *, /, etc. Dicom deals with numerous other operators. Those are listed in Operator Reference in order of their precedence. You can also find this list in Dicom Explorer.

 General Rules 1 You can write expressions in a Dicom Document or Dicom Calculator. Usually a Document is used to calculate many related expressions for a particular task. For ad-hoc calculation Calculator can be used. 2 Enclose any expression within the begin and end tags when you are writing in a Document. The default begin tag and end tag are [' and '] respectively. So, to evaluate 1+2*3/4 in a document, you have to write ['1+2*3/4']. 3 You can define suitable begin and end tag of your choice, by using _DOC:, _BEGIN, and _END commands. 4 Do not use any tag when you are writing expression in Calculator. 5 Use ";" (semicolon) to separate expressions or commands. Example: length in {inch.}; area in {inch.}^2; x=5 ft; mArea=x^2 Rules for Dimension 6 Allowable operators in a dimension are as follows: “*” : Multiplication operator. Associativity is left to right. No operator between two units also mean multiplication. “/” : Division operator. Associatively is left to right. “^” or “**” : Exponentiation operator. Exponentiation has higher precedence than multiplication or division. 7 Dot, [], or {} with a unit are optional, Example: {acre.} is same as acre 8 Blank between two units is optional if dot is used. Example: acre.ft. Blank between two units is necessary if dot, [] or {} is not used. Example: acre ft 9 A “*” can also be used to mean multiplication. Example: acre*ft 10 Use “/ “ in case of “per”. Example: Btu./h./sft. This is not same as Btu./h.sft. The second unit means Btu./(h.sft.) 11 If you do not know the exact symbol for writing a particular unit, you can select it from the explorer. 12 To convert one unit to another in an expression, you can use converter operator ("to" or "->"). For example, to convert ft. to {inch.} write ft.-> {inch.} or ft. to {inch.} the result will be obviously 12 {inch.}