Environmental Engineering Reference
In-Depth Information
default data type is 'double.' It corresponds to a 64 bit
6
representation on
most computers, in contrast to 'single' or 'float,' which corresponds to a 32 bit
representation only.
The data type of a variable can be asked for by the 'class' command. Example:
what is the data type of
pi
?
You convert from default double to float using the 'single' command:
Note that there are eight significant digits. That holds for all singles, as will
become clear soon. Example:
response observe that the number consists of two parts:
the significant or mantissa (in front of the 'e') and the exponent (behind the 'e'). The
'e' obviously indicates the start of the exponent. All doubles or singles are
represented this way. Thus it is clear that
From the MATLAB
®
or:
Internally both the mantissa and the exponent are stored as binary numbers, i.e.
represented not to the basis 10, but to the basis 2. This is nearby, as the binary
system knows only 0 and 1 as digits, which corresponds to the two states of a bit.
Real numbers are represented on the computer internally by floating point numbers
of different type; most important are the just mentioned
double
and
single
.
MATLAB
constructs the single and double data type according to IEEE
7
Standard 754. A single is stored in 32 bits. Any value stored as a double requires
64 bits, formatted as shown in the Table
1.1
:
®
6
A binary digit on a computer, which can take only two states: 0 or 1.
7
Institute of Electrical and Electronics Engineers.