|GNU Octave Manual Version 3|
by John W. Eaton, David Bateman, Søren Hauberg
Paperback (6"x9"), 568 pages
RRP £24.95 ($39.95)
4 Numeric Data Types
A numeric constant may be a scalar, a vector, or a matrix, and it may contain complex values.
The simplest form of a numeric constant, a scalar, is a single number that can be an integer, a decimal fraction, a number in scientific (exponential) notation, or a complex number. Note that by default numeric constants are represented within Octave in double-precision floating point format (complex constants are stored as pairs of double-precision floating point values). It is however possible to represent real integers as described in section 4.3 Integer Data Types. Here are some examples of real-valued numeric constants, which all have the same value:
105 1.05e+2 1050e-1
To specify complex constants, you can write an expression of the form
3 + 4i 3.0 + 4.0i 0.3e1 + 40e-1i
all of which are equivalent. The letter ‘i’ in the previous example
stands for the pure imaginary constant, defined as
For Octave to recognize a value as the imaginary part of a complex constant, a space must not appear between the number and the ‘i’. If it does, Octave will print an error message, like this:
octave:13> 3 + 4 i parse error: 3 + 4 i ^
You may also use ‘j’, ‘I’, or ‘J’ in place of the ‘i’ above. All four forms are equivalent.
- Built-in Function: double (x)
- Convert x to double precision type.
- Function File: single (val)
- Convert the numeric value val to single precision.
Note: this function currently returns its argument in double precision. Support for a single-precision numeric data type will be added in future versions of Octave.
- Built-in Function: complex (val)
- Built-in Function: complex (re, im)
- Convert x to a complex value.
|ISBN 095461206X||GNU Octave Manual Version 3||See the print edition|