@#
@# This is the source for the Adime docs, in Allegro's custom format. Read
@# allegro/docs/makedoc.c for a description of what is going on...
@#
@ignore_css
@multiwordheaders
@#locale=latin1
@document_title=Adime - Syntax of Numerical Expressions
@html_footer=Back to Contents
@rtfh=Adime Expressions
@$\input texinfo
@$@setfilename expressi.inf
@$@settitle Adime Expressions
@$@setchapternewpage odd
@$@paragraphindent 0
@$@setchapternewpage off
@# This should remain commented at the moment (dvi output) @$@finalout
@$
@$@ifinfo
@$@direntry
@$* Adime Expressions: (expressi). About Expressions in Adime
@$@end direntry
@$This is the Info version of the Adime Expressions Manual
@$
@$By Sven Sandberg
@$@end ifinfo
@$
@$@node Top, , (dir), (dir)
@<pre>
@!indent

                              _      _ _
                             /_\  __| (_)_ __  ___
                            / _ \/ _` | | '  \/ -_)
                           /_/ \_\__,_|_|_|_|_\___|

                           Allegro Dialogs Made Easy

                        Syntax of Numerical Expressions

                              by Shawn Hargreaves


@indent
@</pre>



@headingnocontent
Expressions

This section completely describes the expressions that can be typed in the
input fields for "%cint", "%cfloat" and "%cdouble" formats. See also the
Authors section in readme.txt and the adime_evaluate() function in adime.txt.

The whole section is cut from the EGG system by Shawn Hargreaves. For more
info, see the the authors section in readme.txt.

Numbers may be written in decimal (e.g. 42, 1.2345) or in hex (e.g.
0xDEADBEEF). Boolean logic works identically to C, with zero representing
false and nonzero being true.

Binary operators:
<pre>
   +        addition
   -        subtraction (may be unary negation, depending on context)
   *        multiplication
   /        division
   ^        raising to a power
   %        integer modulus (remainder after division)
   |        logical 'or'
   &        logical 'and'
   ==       equality test
   !=       inequality test
   &lt        less than test
   &lt=       less than or equal to test
   &gt        greater than test
   &gt=       greater than or equal to test
</pre>

Unary operators:
<pre>
   -        negation (may be binary subtraction, depending on context)
   !        logical 'not'
   sqrt     square root
   sin      sine (angle in degrees)
   cos      cosine (angle in degrees)
   tan      tangent (angle in degrees)
   asin     inverse sine (angle in degrees)
   acos     inverse cosine (angle in degrees)
   atan     inverse tangent (angle in degrees)
   log      base 10 logarithm
   ln       natural logarithm
   ceil     round up to the next larger integer
   floor    round down to the next smaller integer
   round    round to the closest integer
   abs      absolute value
</pre>
Special values:
<pre>
   rand     a random number between zero and one (inclusive)
   pi       3.14159...
   e        2.71828...
</pre>
Operator precedence (lowest at the top):
<pre>
   |  &
   &lt  &gt  ==  !=  &lt=  &gt=
   +  -
   *  /  %
   ^
   !  sqrt sin cos tan asin acos atan log ln ceil floor round abs
</pre>
Differences from C syntax:
<ul><li>
   The ^ operator raises a number to a power. There is no XOR facility.
<li>
   The boolean logic operators are written with single | and & character,
   rather than || and &&. There are no binary logical operators.
<li>
   The trig routines work with angles in degrees, rather than radians.
<li>
   The 'log' routine returns a base 10 logarithm, and 'ln' returns a
   natural logarithm, unlike C where 'log' is a natural logarithm and
   'log10' is a base 10 logarithm.
<li>
   EGG does not explicitly support function calls. Instead, what look
   like functions are implemented as high priority unary operators. This
   has an almost identical effect, but it means that it is technically
   possible to omit the usual brackets from these, allowing you to write
   "sqrt 10" in the place of "sqrt(10)".
</ul>
