# Difference between revisions of "Shell Commands/Eval"

From MorphOS Library

(Created page with "'''Eval''' - Evaluates a mathematical expression VALUE1/A, OP, VALUE2/M, TO/K, LFORMAT/K <nowiki> VALUE1 - value 1: can be decimal, hexadecimal or octal (see below)...") |
|||

Line 1: | Line 1: | ||

'''Eval''' - Evaluates a mathematical expression | '''Eval''' - Evaluates a mathematical expression | ||

− | VALUE1/A, OP, VALUE2/M, TO/K, LFORMAT/K | + | VALUE1/A, OP, VALUE2/M, TO/K, LFORMAT/K, HEX/S |

<nowiki> | <nowiki> | ||

VALUE1 - value 1: can be decimal, hexadecimal or octal (see below) | VALUE1 - value 1: can be decimal, hexadecimal or octal (see below) | ||

Line 7: | Line 7: | ||

VALUE2 - value 2: can be decimal, hexadecimal or octal (see below) | VALUE2 - value 2: can be decimal, hexadecimal or octal (see below) | ||

TO - filename where to redirect eval result | TO - filename where to redirect eval result | ||

− | LFORMAT - formatting string used to print the answer (see below)</nowiki> | + | LFORMAT - formatting string used to print the answer (see below) |

+ | HEX - prints the result in hexadecimals</nowiki> | ||

About VALUE1 and VALUE2: | About VALUE1 and VALUE2: | ||

## Latest revision as of 14:17, 5 January 2016

**Eval** - Evaluates a mathematical expression

VALUE1/A, OP, VALUE2/M, TO/K, LFORMAT/K, HEX/S

VALUE1 - value 1: can be decimal, hexadecimal or octal (see below) OP - a supported operator (see below) VALUE2 - value 2: can be decimal, hexadecimal or octal (see below) TO - filename where to redirect eval result LFORMAT - formatting string used to print the answer (see below) HEX - prints the result in hexadecimals

About VALUE1 and VALUE2:

- Hexadecimal numbers are indicated by either a leading Ox or #x.
- Octal numbers are indicated by either a leading 0 or a leading #.
- Alphabetical characters are indicated by a leading single quotation mark (`) and are evaluated as their ASCII equivalent.

The LFORMAT keyword specifies the formatting string used to print the answer. You can use %X (hexadecimal), %O (octal), %N (decimal), or %C (character). The %X and %O options require a number of digits using the LFORMAT keyword, you can specify to print a new line by including *N in your string.

Supported Operations:

addition + subtraction - multiplication * division / modulo mod, M, m, or % bitwise AND & bitwise OR | bitwise NOT ~ left shift Ish, L, or | right shift rsh, R, or r negation - exclusive OR xor, X, or x bitwise eqv, E, or e equivalence Example: SYS:> EVAL 0x5f / 010 LFORMAT="The answer is %X4*N" The answer is 000B SYS:>