- publishing free software manuals
GNU Octave Manual Version 3
by John W. Eaton, David Bateman, Søren Hauberg
Paperback (6"x9"), 568 pages
ISBN 095461206X
RRP £24.95 ($39.95)

Get a printed copy>>>

3.1 Built-in Data Types

The standard built-in data types are real and complex scalars and matrices, ranges, character strings, a data structure type, and cell arrays. Additional built-in data types may be added in future versions.

The data type of a variable can be determined and changed through the use of the following functions.

Built-in Function: class (expr)

Return the class of the expression expr, as a string.

Function File: isa (x, class)
Return true if x is a value from the class class.

Function File: cast (val, type)
Convert val to data type type.

See also int8, uint8, int16, uint16, int32, uint32, int64, uint64, double

Loadable Function: typecast (x, type)
Converts from one datatype to another without changing the underlying data. The argument type defines the type of the return argument and must be one of 'uint8', 'uint16', 'uint32', 'uint64', 'int8', 'int16', 'int32', 'int64', 'single' or 'double'.

An example of the use of typecast on a little-endian machine is

x = uint16 ([1, 65535]);
typecast (x, 'uint8')
=> [   0,   1, 255, 255]

See also cast, swapbytes

Function File: swapbytes (x)
Swaps the byte order on values, converting from little endian to big endian and visa-versa. For example

swapbytes (uint16 (1:4))
=> [   256   512   768  1024]

See also typecast, cast

ISBN 095461206XGNU Octave Manual Version 3See the print edition