home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacFormat España 21
/
macformat_21.iso
/
Shareware
/
Programación
/
VideoToolbox
/
VideoToolboxSources
/
Nan.c
< prev
next >
Wrap
Text File
|
1995-08-13
|
1KB
|
45 lines
/*
Nan.c
This file declares a global constant, Nan, that represents a const double
with the value nan("21"). Here's a typical use:
x=Nan;
"Nan" is defined in VideoToolbox.h as *(double *)__NAN. The virtue of this
approach, rather than just computing a NAN, e.g. 0.0/0.0, is that it's faster.
Secondly, there's bug in the THINK C Debugger (versions 6.01 through 7.03) on
the PowerBook 170 that causes it to stop with a fatal error message when trying
to compute 0.0/0.0 while Virtual Memory is enabled.
This scheme should also work fine as native code on the PowerPC.
HISTORY:
5/94 dgp wrote it.
7/29/94 dgp added support for Metrowerks CodeWarrior C compiler.
7/31/94 dgp changed NaN code from 4 to 21.
*/
#define code 21 /* means "attempted to create a NaN with a zero code" */
#if (THINK_C || THINK_CPLUS || SYMANTEC_C)
#if __option(double_8)
const short __NAN[]={ 0x7FF0, code<<5, 0, 0 };
#else
#if !__option(native_fp)
const short __NAN[]={ 0x7FFF, 0x7FFF, code, 0, 0, 0 };
#elif __option(mc68881)
const short __NAN[]={ 0x7FFF, 0, code, 0, 0, 0 };
#else
const short __NAN[]={ 0x7FFF, code, 0, 0, 0 };
#endif
#endif
#endif
#if __MWERKS__
#if __ieeedoubles__
const short __NAN[]={ 0x7FF0, code<<5, 0, 0 };
#else
#if __MC68881__
const short __NAN[]={ 0x7FFF, 0, code, 0, 0, 0 };
#else
const short __NAN[]={ 0x7FFF, code, 0, 0, 0 };
#endif
#endif
#endif