_ _ _ /_\ __| (_)_ __ ___ / _ \/ _` | | ' \/ -_) /_/ \_\__,_|_|_|_|_\___| Allegro Dialogs Made Easy Syntax of Numerical Expressions by Shawn Hargreaves ===================================== ============ 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: + 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 < less than test <= less than or equal to test > greater than test >= greater than or equal to test Unary operators: - 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 Special values: rand a random number between zero and one (inclusive) pi 3.14159... e 2.71828... Operator precedence (lowest at the top): | & < > == != <= >= + - * / % ^ ! sqrt sin cos tan asin acos atan log ln ceil floor round abs Differences from C syntax: The ^ operator raises a number to a power. There is no XOR facility. The boolean logic operators are written with single | and & character, rather than || and &&. There are no binary logical operators. The trig routines work with angles in degrees, rather than radians. 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. 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)".