Mathematics Previous page   Next Page

Largest and Smallest Numbers of Type double and single

This section explains the largest and smallest numbers of data types double and single. This section covers the following topics:

Largest Double- and Single-Precision Numbers

The MATLAB command realmax returns the largest value that you can represent as a double-precision floating-point number.

When the result of an operation on numbers of type double exceeds realmax, MATLAB returns Inf.

Similarly, the MATLAB command realmax('single') returns the largest value that you can represent as a single-precision number.

Note that realmax for type double is much larger than realmax('single'), because the range of numbers that you can represent in single-precision is more limited than in double-precision.

When the result of an operation on numbers of type single exceeds realmax('single'), MATLAB returns Inf of class single. For example,

Because realmax is larger than realmax('single'), performing the same computation in double precision returns a finite answer.

Smallest Positive Double- and Single-Precision Numbers

The MATLAB command realmin returns the smallest positive normalized floating-point number that you can represent in double precision.

When the result of a computation on numbers of type double is a positive number that is less than realmin, MATLAB returns either 0 or a subnormal floating-point number, that is, one that is not in standard form.

Similarly, there is a smallest positive normalized floating-point number that you can represent in single precision, whose value is returned by realmin('single').

Because realmin is less than realmin('single'), operations that return a nonzero double-precision result in standard form might return 0 or a subnormal answer when you do the same operations in single precision.


Previous page  Example -- Writing M-Files for Different Data Types References Next page

© 1994-2005 The MathWorks, Inc.