operations on single precision numbers unstable in matlab 7.1 (64bit ) vesions and higher

Robert Oostenveld r.oostenveld at FCDONDERS.RU.NL
Tue Nov 28 16:47:03 CET 2006

Dear all,

Ali quite convincingly demonstrated this bug in Matlab.

Sofar, we have only seen it on the 64 bit linux machines running 64
bit matlab, which means all the nodes in the FCDC mentat cluster.

Desktop PCs running a 32 bit version of Windows+matlab are not
affected. Also 32 bit linux machines (e.g. loke and odin in the FCDC)
are unaffected. I don't know about 64 bit Mac OS X versions, but the
32 bit Mac OS X does not have a problem either. We are not yet
running 64 bit Windows at the FCDC, so we do not have experience with
those yet.

Regarding fieldtrip: if you want to use single precision (to save
memory/quota), I suggest that you only store the data on disk in
single precision, and that you do struct2double (as JM suggested) as
soon as you read the data from disk.

I will contact Mathworks about this serious bug.

best regards

On 28 Nov 2006, at 13:55, Ali Mazaheri wrote:

> Dear all,
> The long subject captions says it all.
> I just recently discovered that solutions to the  low level
> functions in matlab7.1 and  higher run on a 64 bit platform  become
> unstable when using single precision.
> This problem does not appear to be  present on matlabs running on a
> 32 bit platform.
> .
> A simple example of this problem is as follows
> a=[1 2]
> b=[1 2];
> >> a/b
> ans = 1
> NOW in single precision
> a=single(a);
> b=single(b);
> >> a/b
> ans = 1.9074 e-05
> the problem of course become much more compounded when doing more
> higher level functions such as detrend. I am completely unable to
> do a linear detrend on
> single precious data.
> regards
> Ali

More information about the fieldtrip mailing list