Simple Numeric Scalar Comments

General:This frame introduces you to simple numbers in Glee. Numbers may be integer or floating (containing decimals). They may be supplied in normal or scientific notation. All numbers in Glee are vectors (sequences of 1 or more elements).

Scalar operation: A simple operation between two scalars (in this case "1" and "2" operated on by "+") yields a scalar "3". "1+2=3".

Floating point: Glee wants to let its users view numbers as numbers. The user shouldn't have to be concerned with integers and floating point numbers (numbers called floats which contain decimals). But the computer deals with these kinds of numbers differently and Glee has to deal with the computer. Glee has a simple rule. If there is a float involved in an operation, all operands are "promoted" to float before beginning and the result will be a float. Later you will see how to turn the result to an integer (which takes ½ as much storage as a float). We'll also see later, when "indexing", Glee views floats differently than integers.

Signed numbers:Numeric operations can produce results less than zero. You're probably used to seeing these displayed with a dash ("-"). For reasons I'll soon discuss, this isn't good for Glee or for you. Glee presents negative numbers by preceeding them with the underbar "_".

Entering signs: If you need to enter a negative number, you use the underbar "_". Glee doesn't allow any spaces between the underbar and the first digit. Here we see vividly why Glee wants to distinguish between the minus sign and the minus operation. 1 minus negative 2 yields 3.

Monadic operations: The dash "-" with something on its left and nothing on its right is called the "negate" operator. It is a "monadic" operator ... has only one argument. Contrast this with "1-2" (read 1 minus 2). Then the dash is a "dyadic" operator called "minus". It has arguments on both sides (1 on the left and 2 on the right).

Consecutive operators: Here we have "1"; then "-" (which yields negative 1); then another "-" (which negates that negative 1 yielding positive 1). Glee, working from left to right is not concerned. Its rules are very simple. Take what is on the left and right and operate on them. If what is on the right is not an operand (e.g. in this case it is an operator), then do the monadic operation working just with the left. Then proceed to the right with the result.

Consecutive Operations proceeding: Glee picks up the "1"; then sees the "-"; looks further and sees another "-". Here is backs up and performs the monadic operation "1-" yielding "_1". It then proceeds again and sees the "-" before the 2; looks further and sees the "2". Now it knows it has a dyadic operation "_1 - 2" yielding "_3". Contrast this with the "1- _2" example above which yielded 3, not _3.