home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power-Programmierung
/
CD2.mdf
/
c
/
library
/
mslang
/
mathfi
/
mathfix.c
Wrap
Text File
|
1994-03-24
|
2KB
|
116 lines
double check_dbl( double d, int *flip )
{
*flip = 0;
if ( d > (PI/2.0) ) {
do {
*flip ^= 1;
d -= PI;
} while (d > PI/2.0);
}
else if ( d < -(PI/2.0) ) {
do {
*flip ^= 1;
d += PI;
} while (d < -(PI/2.0) );
}
return( d );
}
#ifndef NOLNGDBL
long double check_dbll( long double d, int *flip )
{
*flip = 0;
if ( d > (PI/2.0) ) {
do {
*flip ^= 1;
d -= PI;
} while (d > PI/2.0);
}
else if ( d < -(PI/2.0) ) {
do {
*flip ^= 1;
d += PI;
} while (d < -(PI/2.0) );
}
return( d );
}
#endif
double xtan( double t )
{
if ( t <= -(PI/2.0) ) {
while ( t < -(PI/2.0) )
t += PI;
}
else if ( t > (PI/2.0) ) {
while ( t > PI/2.0 )
t -= PI;
}
return( tan( t ) );
}
#ifndef NOLNGDBL
LONG_DOUBLE xtanl( LONG_DOUBLE t )
{
if ( t <= -(PI/2.0) ) {
while ( t < -(PI/2.0) )
t += PI;
}
else if ( t > (PI/2.0) ) {
while ( t > PI/2.0 )
t -= PI;
}
return( tanl( t ) );
}
#endif
double xsin( double t )
{
int f;
t = check_dbl(t, &f );
t = sin( t );
if ( f )
return( -t );
else
return( t );
}
#ifndef NOLNGDBL
LONG_DOUBLE xsinl( LONG_DOUBLE t )
{
int f;
t = check_dbll(t, &f );
t = sinl( t );
if ( f )
return( -t );
else
return( t );
}
#endif
double xcos( double t )
{
int f;
t = check_dbl(t, &f );
t = cos( t );
if ( f )
return( -t );
else
return( t );
}
#ifndef NOLNGDBL
LONG_DOUBLE xcosl( LONG_DOUBLE t )
{
int f;
t = check_dbll(t, &f );
t = cosl( t );
if ( f )
return( -t );
else
return( t );
}
#endif