Eric Fleegal's WebLog

. . . .

Single Vs. Double ...

It’s almost Christmas as evidenced by how dead the office is; it’s pretty common for people at Microsoft to take-off the week of Christmas, and sometimes the following week.  MS is fairly generous with holidays, giving us both Christmas Eve and Christmas day.  This allows people to spend only 3 vacation days for a full week’s vacation.

 

A few readers have asked if double-precision is so much better than single, why do we even support single-precision? 

 

There are a number of reasons, but perhaps the most important are the following:

·        singles are half the size of doubles, reducing memory & bandwidth requirements. 

·        singles are the same size as DWORDs and thus can be moved in an atomic operation using 32bit integer registers (on occasion this can be important when doing things like InterlockedExchange on floating-point numbers).

·        some platforms support intrinsic, complicated operations in single-precision (e.g. SSE) but not in double precision

·        some hardware platforms do not natively support in-chip double precision computation; on such chips double precision must be emulated.

·        Single precision computations are faster than double precision on some platforms.  However, it is NOT safe to assume that singles are always at least as fast as doubles.  If double-precision is the native precision, the extra cost of narrowing results to single-precision MAY be quite high… much higher, in fact, than the cost associated with the memory overhead of doubles (cache misses etc). 

·        some 32-bit HW supports only integer operations—it’s faster to emulate single precision on these platforms than double precision

 

For many applications, it’s preferable to store input and final results in single precision, but to perform all the intermediate computations in the highest precision that is practical on the target architecture.

Published Tuesday, December 21, 2004 1:45 PM by ericflee

Comments

No Comments
Anonymous comments are disabled

© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Microsoft
Page view tracker