Blame src/lib/libast/port/astmath.c
|
Packit |
992a25 |
/***********************************************************************
|
|
Packit |
992a25 |
* *
|
|
Packit |
992a25 |
* This software is part of the ast package *
|
|
Packit |
992a25 |
* Copyright (c) 1985-2011 AT&T Intellectual Property *
|
|
Packit |
992a25 |
* and is licensed under the *
|
|
Packit |
992a25 |
* Eclipse Public License, Version 1.0 *
|
|
Packit |
992a25 |
* by AT&T Intellectual Property *
|
|
Packit |
992a25 |
* *
|
|
Packit |
992a25 |
* A copy of the License is available at *
|
|
Packit |
992a25 |
* http://www.eclipse.org/org/documents/epl-v10.html *
|
|
Packit |
992a25 |
* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
|
|
Packit |
992a25 |
* *
|
|
Packit |
992a25 |
* Information and Software Systems Research *
|
|
Packit |
992a25 |
* AT&T Research *
|
|
Packit |
992a25 |
* Florham Park NJ *
|
|
Packit |
992a25 |
* *
|
|
Packit |
992a25 |
* Glenn Fowler <gsf@research.att.com> *
|
|
Packit |
992a25 |
* David Korn <dgk@research.att.com> *
|
|
Packit |
992a25 |
* Phong Vo <kpv@research.att.com> *
|
|
Packit |
992a25 |
* *
|
|
Packit |
992a25 |
***********************************************************************/
|
|
Packit |
992a25 |
/*
|
|
Packit |
992a25 |
* used to test if -last requires -lm
|
|
Packit |
992a25 |
*
|
|
Packit |
992a25 |
* arch -last -lm
|
|
Packit |
992a25 |
* ---- ----- ---
|
|
Packit |
992a25 |
* linux.sparc sfdlen,sfputd frexp,ldexp
|
|
Packit |
992a25 |
*/
|
|
Packit |
992a25 |
|
|
Packit |
992a25 |
#if N >= 8
|
|
Packit |
992a25 |
#define _ISOC99_SOURCE 1
|
|
Packit |
992a25 |
#endif
|
|
Packit |
992a25 |
|
|
Packit |
992a25 |
#include <math.h>
|
|
Packit |
992a25 |
|
|
Packit |
992a25 |
int
|
|
Packit |
992a25 |
main()
|
|
Packit |
992a25 |
{
|
|
Packit |
992a25 |
#if N & 1
|
|
Packit |
992a25 |
long double value = 0;
|
|
Packit |
992a25 |
#else
|
|
Packit |
992a25 |
double value = 0;
|
|
Packit |
992a25 |
#endif
|
|
Packit |
992a25 |
#if N < 5
|
|
Packit |
992a25 |
int exp = 0;
|
|
Packit |
992a25 |
#endif
|
|
Packit |
992a25 |
|
|
Packit |
992a25 |
#if N == 1
|
|
Packit |
992a25 |
return ldexpl(value, exp) != 0;
|
|
Packit |
992a25 |
#endif
|
|
Packit |
992a25 |
#if N == 2
|
|
Packit |
992a25 |
return ldexp(value, exp) != 0;
|
|
Packit |
992a25 |
#endif
|
|
Packit |
992a25 |
#if N == 3
|
|
Packit |
992a25 |
return frexpl(value, &exp) != 0;
|
|
Packit |
992a25 |
#endif
|
|
Packit |
992a25 |
#if N == 4
|
|
Packit |
992a25 |
return frexp(value, &exp) != 0;
|
|
Packit |
992a25 |
#endif
|
|
Packit |
992a25 |
#if N == 5
|
|
Packit |
992a25 |
return isnan(value);
|
|
Packit |
992a25 |
#endif
|
|
Packit |
992a25 |
#if N == 6
|
|
Packit |
992a25 |
return isnan(value);
|
|
Packit |
992a25 |
#endif
|
|
Packit |
992a25 |
#if N == 7
|
|
Packit |
992a25 |
return copysign(1.0, value) < 0;
|
|
Packit |
992a25 |
#endif
|
|
Packit |
992a25 |
#if N == 8
|
|
Packit |
992a25 |
return signbit(value);
|
|
Packit |
992a25 |
#endif
|
|
Packit |
992a25 |
}
|