Chapter 3. Basic Data Types and Mechanisms

Table of Contents

3.1. Numeric Types
3.1.1. Integer
3.1.2. Real
3.1.3. Fixed-point Real
3.1.4. Number Operators
3.2. Logical Types
3.3. Strings
3.4. Lists and Arrays
3.5. Constants
3.6. Operators and Expressions
3.7. Comments
3.8. Reserved Words
3.9. Memory Management

3.1. Numeric Types

A number in Gamma is any integer, real, or fixed-point value.

3.1.1. Integer

An integer is any 32-bit integer number. Integers can be read and written in the following representations:

    decimal

    Example: 45, 129000

    hexadecimal (start with 0x)

    Example: 0xf12

    octal (start with 0o)

    Example: 0o777

    binary (start with 0b)

    Example: 0b101001

    character (enclosed by ' ')

    Example: 's'

3.1.2. Real

A real number is a 64-bit double precision floating point number. It can contain a decimal point and it may end with the letter e followed by a signed exponent.

Examples: 0.1, 235.02013576, 5e-2, 3.74e-7

3.1.3. Fixed-point Real

A fixed-point real number is one that is represented by an integer, where the high 16 bits represent an integer value, and the low 16 bits represent a mantissa. There are very few reasons to work with fixed-point numbers unless floating-point error in numeric comparison is intolerable. Fixed-point numbers are created by any numeric function so long as the value of the symbol _fixed_point_ is non-nil. The default value of _fixed_point_ is nil, so that floating point numbers of type real are created by default.

3.1.4. Number Operators

The following operators can be used with numeric data:

    arithmetic (+, -, *, /, %, div)

    Example:

    Gamma> 2 + 3;
    5
    			

    logical (!, &&, ||)

    Example:

    Gamma> !2.75;
    nil
    			

    comparison (!=, ==, <, <=, >, >= )

    Example:

    Gamma> 2 != 3;
    t
    		  

    bitwise (<<, >>, ~, &, |, ^ )

    Example:

    Gamma> bin(25);
    0b00011001
    Gamma> bin(25 << 1);
    0b00110010