Mathematics Previous page   Next Page

Data Type single

To assign the data type single to a numbers or variable, use the command single. For example,

sets the value of a to be 5 with data type single.

Storing a number as type single require only half as much memory as storing it as type double. You can compare how many bytes of memory are used to store 5 as type single versus type double using the whos command.

When you convert a number of type double to type single, MATLAB rounds the number to the nearest single-precision number. This can change the stored value slightly. For example,

You can return an upper bound for how much the stored value of a number changes when you convert it to single using the eps command, as described in The Function eps.


Previous page  Single-Precision Mathematics Single-Precision Arithmetic Next page

© 1994-2005 The MathWorks, Inc.