next up previous contents index
Next: Sequences ([]) Up: Data Previous: Data

Atomic Data Types

There are four primitive atomic data types: booleans, integers, characters and floats.

  The boolean type bool can have one of two values t or f. The standard logical operations (eg. not, and, or, xor, nor, nand) are predefined. The operations and, or, xor, nor, nand all use infix notation. For example:

  The integer type int is the set of (positive and negative) integers that can be represented in the fixed precision of a machine-sized word. The exact precision is machine dependent, but will always be at least 32-bits. The standard functions on integers (+, -, *, /, ==, >, <, negate, ...) are predefined, and use infix notation (see Appendix A for the precedence rules). For example:

    tabular5578

Overflow will return unpredictable results.

  The character type char is the set of ASCII characters. The characters have a fixed order and all the comparison operations (eg. ==, <, >=,...) can be used. Characters are written by placing a ` in front of the character. For example:

    tabular5597

    tabular5617

    tabular5637

The global variables space, newline and tab are bound to the appropriate characters.

  The type float is used to specify floating-point numbers. The exact representation of these numbers is machine specific, but NESL\ tries to use 64-bit IEEE when possible. Floats support most of the same functions as integers, and also have several additional functions (eg. round, truncate, sqrt, log,...). Floats must be written by placing a decimal point in them so that they can be distinguished from integers.

    tabular5658

    tabular5676

There is no implicit coercion between scalar types. To add 2 and 3.0, for example, it is necessary to coerce one of them: e.g.

    tabular5694

A complete list of the functions available on scalar types can be found in Appendix B.1.



next up previous contents index
Next: Sequences ([]) Up: Data Previous: Data



Jonathan Hardwick
Tue Nov 28 13:57:00 EST 1995