Eval
14-Jan-2004

Introduction

Eval is a scientific/programmer’s calculator that evaluates expressions you enter and displays the resulting value of the expression. You can control Eval from the keyboard, by point and click, or any combination of the two.

Results are displayed on the top line of the window; expressions are entered on the second line.

Basics

You can control the result number format by selecting f, s or e (for fixed, scientific or engineering notation) and by selecting a number of decimal places (0..15).

You can copy the current result to the clipboard by tapping the result readout window and then selecting Copy to Clipboard from the popup menu.

You can choose to work in either degrees or radians by tapping the rad/deg readout and selecting rad or deg from the popup menu.

The input and output radix can be specified separately as decimal (d), hexadecimal (h), octal (o) or binary (b). The input radix controls how numbers are interpreted when you enter them in the expression; the output radix controls how results are displayed. For example, to convert numbers from decimal to hex, set the input radix to d and the output radix to h. Numbers you enter are then converted from decimal to hex and displayed in the results control. Unlike other calculators, you can display non-integers in hex or octal with significant digits after the decimal place. In e format, the exponent is always displayed in decimal while the mantissa is displayed using the current radix. For example in f 1 format, 1.5 in decimal is 1.4 in octal, 1.8 in hex or 1.1 in binary; in e 8 format, 128.5 in decimal is 2.00400000e2 in octal, 8.08000000e1 in hex or 1.00000001e7 in binary.

You have the option of formatting the result with or without commas -- this is controlled by tapping on the result window and selecting With Commas or Without Commas from the popup menu. The menu item corresponding to the current setting has a check mark next to it. Formatting with commas makes large numbers easier to read, but may cause problems if you copy the result to the clipboard and then paste it into another application. In decimal and octal commas are inserted every 3 digits, in hex and binary every 4 digits.

Expressions are evaluated internally using standard IEEE floating point arithmetic which is accurate to roughly 15 significant digits. Errors can accumulate in certain expressions or when lengthy or numerically unstable calculations are performed.

If the expression you enter cannot be evaluated—either because of a syntax error or because it involves an illegal operation such as division by zero, Error is displayed instead of a result; if parentheses do not match, Parenthesis Error is displayed.

Menus

There are two items in the main menu, namely File and Edit. Under File, the options are Skin, About Eval, and Exit:

Recalc

This command lets you select a either Auto or Manual recalculation. In manual recalculation mode, you must tap the = key to evaluate the current input line and display the result. In automatic recalculation mode, the current expression is automatically re-evaluated every time you modify it. The advantage of automatic mode is that it saves you from having to tap the = key when you are done entering your input. The disadvantage is that in the process of entering the expression, the result keeps changing and will display Error if the current expression is missing a required operand or has unbalanced parentheses.

Skin

This command lets you select a skin (a replacement image) for the face of the calculator. Currently there are three options: Dark Textured, Low Contrast, and High Contrast.

About Eval

This displays the Eval about box.

Exit

This is equivalent to tapping the off button; it terminates Eval and closes its window.

Under Edit, the options are Undo, Cut, Copy and Paste; these commands undo, cut, copy and paste text in the input expression in the normal manner. To copy the contents of the result to the clipboard, tap on the result window and select Copy to Clipboard from the popup menu.

Command Bar Icons

For convenience cut, copy and paste and left and right arrow are available as icons on the command bar at the bottom of the screen. Cut, copy and paste apply to the input expression and can be used to rearrange its text. To copy the contents of the result to the clipboard, tap on the result window and select Copy to Clipboard from the popup menu. Left and right arrow move the caret (insertion point) left and right by one character position in the input expression.

Using Eval from the keyboard

Simply type in an expression such as sqrt(2.5*(15+pi)) and press Enter or =. The result is immediately displayed in the top line of the Eval window. Spaces in expressions are ignored except within numbers or operator or function names. Input is case sensitive and must be in lower case except for the hexadecimal digits A..F which must be entered as upper case.

Using Eval by point and click

Clicking one of the following buttons triggers the corresponding action:

Button        Action

clr              clears the current expression and result lines

<-             (backspace) erases the last character or highlighted text in the current expression

=                evaluates the current expression and displays the result

help           displays this help file

off              shuts down Eval and closes its window

Clicking one of the following buttons replaces the current selection in the expression with the characters on the button:

Button        Action

0..1             Enters the corresponding digit

2..7             Enters the corresponding digit (unless input radix is binary)

8..9             Enters the corresponding decimal digit (if input radix is decimal or hex)

A..F            Enters the corresponding hexadecimal digit (if input radix is hex)

.                 Enters “.”

e                Enters “e” (this works both for entering the constant e or exponents in scientific notation)

pi               Enters “pi”

Clicking one of the following buttons does one of two things, depending on whether any text is highlighted in the expression. If no text is highlighted, then the character on the button is entered into the expression at the location of the caret. If text is highlighted, the highlighted text is placed in parentheses, then the character on the button is entered.

Button        Action

+                Enters “+”

–                Enters “–“

*                 Enters “*”

/                 Enters “/”

^                Enters “^”

and            Enters “and”

or               Enters “or”

xor             Enters “xor”

<<              Enters “<<”

>>              Enters “>>”

Clicking one of the following buttons does one of two things, depending on whether any text is highlighted in the expression. If no text is highlighted, then the characters on the button are entered into the expression at the location of the caret, followed by an empty set of parentheses. The caret is then backed up so that subsequent characters will be entered between the parentheses. If text is highlighted, then the characters on the button are entered just before the first highlighted character in the expression, the highlighted text is placed in parentheses, and the caret is moved just beyond the final right pren.

Button        Action

(..)              Enters “()”

(..)^2          Enters “()^2

1/(..)           Enters “1/()”

abs             Enters “abs()“

acos           Enters “acos()“

asin            Enters “asin()“

atan           Enters “atan()“

atan2         Enters “atan2(,)“

cos             Enters “cos()“

exp            Enters “exp()“

hypot         Enters “hypot(,)“

int              Enters “int()”

ln               Enters “ln()“

log             Enters “log()“

mod           Enters “mod(,)“

sin              Enters “sin()“

sqrt            Enters “sqrt()“

tan             Enters “tan()“

not             Enters “not()”

For example, to compute sin(45) using point and click, first click the sin button and then click the 4 and 5 buttons and finally click the = button. Or you can click the 4 and 5 buttons first, highlight the characters 45 in the expression, click the sin button and then the = button.

Expressions

In the absence of parentheses, higher precendence operations (see list below) are performed before lower precedence ones. Equal precedence operations are performed left to right. For example, in the expression 1+2*3, the multiplication is performed before the addition.

Numbers may be optionally be entered using scientific notation such as 1.23e-5 (no spaces allowed). Numbers are interpreted according to the current input radix.

Constants

Name         Description

e                e (2.71828...)

pi                pi (3.14159...)

Operators

Name         Description                  Precedence

x+y             addition                         3

x–y             subtraction                    3

x*y             multiplication                 4

x/y              division                          4

–y               negation                        5

x^y             raise x to the y power     6

The following logical operators only work on 32-bit unsigned integers:

not x           complement                  5

x and y       and                               2

x or y          inclusive or                    1

x xor y        exclusive or                   1

x << n         shift x left by n bits         0          (n must be 0..32)

x >> n         shift x right by n bits       0          (n must be 0..32)

Functions

Name         Description

abs(x)         absolute value

acos(x)       arc cosine

asin(x)        arc sine

atan(x)        2-quadrant arc tangent

atan2(y,x)    4-quadrant arc tangent

cos(x)         cosine

exp(x)         exponentiation

hypot(x,y)    sqrt(x*x+y*y)

int(x)           integer part of x

ln(x)            natural logarithm

log(x)          logarithm base 10

mod(x,y)     modulus

sin(x)          sine

sqrt(x)         square root

tan(x)          tangent

Copyright Σ 1997-2004, Jonathan Sachs
All Rights Reserved

This program may be redistributed free of charge as long as the entire program and its accompanying help file are copied intact, including this notice.

Jonathan Sachs
12 Ash Street
Cambridge, MA 02138

jsachs@dl-c.com
http://www.dl-c.com