home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacFormat España 21
/
macformat_21.iso
/
Shareware
/
Programación
/
VideoToolbox
/
VideoToolboxSources
/
fp.c
< prev
next >
Wrap
Text File
|
1995-08-15
|
3KB
|
119 lines
/* fp.c
NOTE: as of System 7.5.1 Apple's fp routines are available on both
PowerPC and 68k Macs, so this file is obsolete.
Apple provides a whole bunch of nice functions that are defined in fp.h, but
unfortunately, at present they only exist on the PowerPC. As a stop-gap, until
Apple provides them for 68k machines as well, I've written these 68k-compatible
equivalents. You can safely include this file in all your projects. This file
omits itself if Apple's versions of the functions are available.
At present this file only defines: ldtox80, x80told, and fpclassify. This replaces
the functions formerly provided by the VideoToolbox Sane.c, which I've now discarded.
You may also want to look at the functions defined in IsNan.c, which are very
similar, though not identical to several fp.h functions.
ldtox80 and x80told convert back and forth between long double (any size)
and 10-byte floating point formats. The 10- and 12-byte formats contain exactly
the same information. The 12-byte format, used by the Motorola 68881 and 68040
floating point chips, has an unused 2-byte gap between the exponent and mantissa.
KNOWN BUGS:
Bosco Tjan reported that Symantec C++ doesn't like this file, as noted below. I'm not
bothering to fix it because as far as I know this file is obsolete. If I'm
wrong, and you need to use this file, let me know and I'll try to fix it.
Undefined "x96tox80,x80tox96,extended80,extended96".
When I changed the code from #if 0 to #if 1 to include SANE.h,
I still got one problem -- extended96 is not defined on PPCs"
HISTORY:
10/8/94 dgp wrote it.
*/
#include "VideoToolbox.h"
#if !defined(__FP__) // Conditional applies to rest of file.
#if 0
#undef INF
#undef PI
#undef NAN
#include <SANE.h> // x96tox80,x80tox96,extended80,extended96
#else
// if extended80 and extended96 are undefined, change the "#if 0" to "#if 1" above.
void x96tox80(extended96 *,extended80 *);
void x80tox96(extended80 *,extended96 *);
#endif
#include <assert.h>
void ldtox80 (long double *xl,extended80 *x80);
void x80told (extended80 *x80,long double *xl);
long int fpclassify(double x);
void ldtox80 (long double *xl,extended80 *x80)
{
double x;
switch(sizeof(long double)){
case 12:
x96tox80((extended96 *)xl,x80);
return;
case 10:
*x80=*(extended80 *)xl;
return;
default:
switch(sizeof(double)){
case 12:
x=*xl;
x96tox80((extended96 *)&x,x80);
break;
case 10:
*(double *)x80=*xl;
break;
default:
assert(0);
}
}
}
void x80told (extended80 *x80,long double *xl)
{
double x;
switch(sizeof(long double)){
case 12:
x80tox96(x80,(extended96 *)xl);
break;
case 10:
*xl=*(long double *)x80;
break;
default:
switch(sizeof(double)){
case 12:
x80tox96(x80,(extended96 *)&x);
*xl=x;
break;
case 10:
*xl=*(double *)x80;
break;
default:
assert(0);
}
}
}
pascal void MyClassExtended(extended80 *,short *) = { 0x3F3C,0x001C,0xA9EB };
long int fpclassify(double x)
{
short n;
extended80 x80;
long double xl;
xl=x;
ldtox80(&xl,&x80);
MyClassExtended(&x80,&n);
return n;
}
#endif