Table of Contents
A number in Gamma is any integer, real, or fixed-point value.
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'
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
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.
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
Copyright © 1995-2010 by Cogent Real-Time Systems, Inc. All rights reserved.