Mac OS 9
fp.h
Go to the documentation of this file.
1 
19 #ifndef __FP__
20 #define __FP__
21 
22 #ifndef __CONDITIONALMACROS__
23 #include <ConditionalMacros.h>
24 #endif
25 
26 #ifndef __MACTYPES__
27 #include <MacTypes.h>
28 #endif
29 
30 /********************************************************************************
31  * *
32  * A collection of numerical functions designed to facilitate a wide * range
33  *of numerical programming as required by C9X. *
34  * *
35  * The <fp.h> declares many functions in support of numerical programming. *
36  * It provides a superset of <math.h> and <SANE.h> functions. Some *
37  * functionality previously found in <SANE.h> and not in the FPCE <fp.h> *
38  * can be found in this <fp.h> under the heading "__NOEXTENSIONS__". *
39  * *
40  * All of these functions are IEEE 754 aware and treat exceptions, NaNs, *
41  * positive and negative zero and infinity consistent with the floating- *
42  * point standard. *
43  * *
44  ********************************************************************************/
45 
46 #if PRAGMA_ONCE
47 #pragma once
48 #endif
49 
50 #ifdef __cplusplus
51 extern "C"
52 {
53 #endif
54 
55 #if PRAGMA_IMPORT
56 #pragma import on
57 #endif
58 
59 #if PRAGMA_STRUCT_ALIGN
60 #pragma options align = mac68k
61 #elif PRAGMA_STRUCT_PACKPUSH
62 #pragma pack(push, 2)
63 #elif PRAGMA_STRUCT_PACK
64 #pragma pack(2)
65 #endif
66 
67 /********************************************************************************
68  * *
69  * Efficient types *
70  * *
71  * float_t Most efficient type at least as wide as float * double_t
72  *Most efficient type at least as wide as double *
73  * *
74  * CPU float_t(bits) double_t(bits) *
75  * -------- ----------------- ----------------- * PowerPC
76  *float(32) double(64) * 68K long
77  *double(80/96) long double(80/96) * x86 double(64)
78  *double(64) *
79  * *
80  ********************************************************************************/
81 #if defined(__MWERKS__) && defined(__cmath__)
82 /* these types were already defined in MSL's math.h */
83 #else
84 #if TARGET_CPU_PPC
85 typedef float float_t;
86 typedef double double_t;
87 #elif TARGET_CPU_68K
88 typedef long double float_t;
89 typedef long double double_t;
90 #elif TARGET_CPU_X86
91 typedef double float_t;
92 typedef double double_t;
93 #elif TARGET_CPU_MIPS
94 typedef double float_t;
95 typedef double double_t;
96 #elif TARGET_CPU_ALPHA
97 typedef double float_t;
98 typedef double double_t;
99 #elif TARGET_CPU_SPARC
100 typedef double float_t;
101 typedef double double_t;
102 #else
103 #error unsupported CPU
104 #endif /* */
105 
106 /********************************************************************************
107  * *
108  * Define some constants. *
109  * *
110  * HUGE_VAL IEEE 754 value of infinity. * INFINITY IEEE
111  *754 value of infinity. * NAN A
112  *generic NaN (Not A Number). * DECIMAL_DIG Satisfies
113  *the constraint that the conversion from * double to decimal and back is
114  *the identity function. *
115  * *
116  ********************************************************************************/
117 #if TARGET_OS_MAC
118 #if TARGET_RT_MAC_MACHO
119 #define HUGE_VAL 1e500 /* compatible with bsd math.h */
120 #else
121 #define HUGE_VAL __inf()
122 #endif
123 #define INFINITY __inf()
124 #define NAN nan("255")
125 #else
126 #define NAN sqrt(-1)
127 #endif
128 
129 #if TARGET_CPU_PPC
130 #define DECIMAL_DIG 17 /* does not exist for double-double */
131 #elif TARGET_CPU_68K
132 #define DECIMAL_DIG 21
133 #endif
134 #endif /* __MWERKS__ && __cmath__ */
135 #if TARGET_OS_MAC
136 /* MSL already defines these */
137 #if !defined(__MWERKS__) || !defined(__cmath__)
138  /********************************************************************************
139  * *
140  * Trigonometric functions *
141  * *
142  * acos result is in [0,pi]. * asin result is in [-pi/2,pi/2]. *
143  * atan result is in [-pi/2,pi/2]. * atan2 Computes the arc
144  *tangent of y/x in [-pi,pi] using the sign of * both arguments to determine
145  *the quadrant of the computed value. *
146  * *
147  ********************************************************************************/
156  double_t cos(double_t x);
157 
166  double_t sin(double_t x);
167 
176  double_t tan(double_t x);
177 
186  double_t acos(double_t x);
187 
196  double_t asin(double_t x);
197 
206  double_t atan(double_t x);
207 
216  double_t atan2(double_t y, double_t x);
217 
218  /********************************************************************************
219  * *
220  * Hyperbolic functions *
221  * *
222  ********************************************************************************/
231  double_t cosh(double_t x);
232 
241  double_t sinh(double_t x);
242 
251  double_t tanh(double_t x);
252 
261  double_t acosh(double_t x);
262 
271  double_t asinh(double_t x);
272 
281  double_t atanh(double_t x);
282 
283  /********************************************************************************
284  * *
285  * Exponential functions *
286  * *
287  * expm1 expm1(x) = exp(x) - 1. But, for small enough arguments, *
288  * expm1(x) is expected to be more accurate than exp(x) - 1. *
289  * frexp Breaks a floating-point number into a normalized fraction * and
290  *an integral power of 2. It stores the integer in the * object pointed
291  *by *exponent. * ldexp Multiplies a
292  *floating-point number by an integer power of 2. * log1p log1p = log(1
293  *+ x). But, for small enough arguments, * log1p is expected to be
294  *more accurate than log(1 + x). * logb Extracts the exponent of
295  *its argument, as a signed integral * value. A subnormal argument is
296  *treated as though it were first * normalized. Thus: * 1 <= x *
297  *2^(-logb(x)) < 2 * modf Returns fractional part of x as
298  *function result and returns * integral part of x via iptr. Note C9X uses
299  *double not double_t. * scalb Computes x * 2^n efficently. This is not
300  *normally done by * computing 2^n explicitly. *
301  * *
302  ********************************************************************************/
311  double_t exp(double_t x);
312 
321  double_t expm1(double_t x);
322 
331  double_t exp2(double_t x);
332 
341  double_t frexp(double_t x, int *exponent);
342 
351  double_t ldexp(double_t x, int n);
352 
361  double_t log(double_t x);
362 
371  double_t log2(double_t x);
372 
381  double_t log1p(double_t x);
382 
391  double_t log10(double_t x);
392 
401  double_t logb(double_t x);
402 
403 #if !TYPE_LONGDOUBLE_IS_DOUBLE
412  long double modfl(long double x, long double *iptrl);
413 
414 #endif /* !TYPE_LONGDOUBLE_IS_DOUBLE */
415 
424  double_t modf(double_t x, double_t *iptr);
425 
434  float modff(float x, float *iptrf);
435 
441  typedef long _scalb_n_type;
450  double_t scalb(double_t x, _scalb_n_type n);
451 
452  /********************************************************************************
453  * *
454  * Power and absolute value functions *
455  * *
456  * hypot Computes the square root of the sum of the squares of its *
457  * arguments, without undue overflow or underflow. * pow Returns x
458  *raised to the power of y. Result is more accurate * than using
459  *exp(log(x)*y). *
460  * *
461  ********************************************************************************/
470  double_t fabs(double_t x);
471 
480  double_t hypot(double_t x, double_t y);
481 
490  double_t pow(double_t x, double_t y);
491 
500  double_t sqrt(double_t x);
501 
502  /********************************************************************************
503  * *
504  * Gamma and Error functions *
505  * *
506  * erf The error function. * erfc Complementary error function.
507  ** gamma The gamma function. * lgamma Computes the base-e logarithm
508  *of the absolute value of * gamma of its argument x, for x > 0. *
509  * *
510  ********************************************************************************/
519  double_t erf(double_t x);
520 
529  double_t erfc(double_t x);
530 
539  double_t gamma(double_t x);
540 
549  double_t lgamma(double_t x);
550 
551  /********************************************************************************
552  * *
553  * Nearest integer functions *
554  * *
555  * rint Rounds its argument to an integral value in floating point *
556  * format, honoring the current rounding direction. *
557  * *
558  * nearbyint Differs from rint only in that it does not raise the inexact *
559  * exception. It is the nearbyint function recommended by the *
560  * IEEE floating-point standard 854. *
561  * *
562  * rinttol Rounds its argument to the nearest long int using the current *
563  * rounding direction. NOTE: if the rounded value is outside *
564  * the range of long int, then the result is undefined. *
565  * *
566  * round Rounds the argument to the nearest integral value in floating *
567  * point format similar to the Fortran "anint" function. That is:
568  ** add half to the magnitude and chop. *
569  * *
570  * roundtol Similar to the Fortran function nint or to the Pascal round. *
571  * NOTE: if the rounded value is outside the range of long int, *
572  * then the result is undefined. *
573  * *
574  * trunc Computes the integral value, in floating format, nearest to *
575  * but no larger in magnitude than its argument. NOTE: on 68K *
576  * compilers when using -elems881, trunc must return an int *
577  * *
578  ********************************************************************************/
587  double_t ceil(double_t x);
588 
597  double_t floor(double_t x);
598 
607  double_t rint(double_t x);
608 
617  double_t nearbyint(double_t x);
618 
627  long rinttol(double_t x);
628 
637  double_t round(double_t x);
638 
647  long roundtol(double_t round);
648 
654 #if TARGET_RT_MAC_68881
655  typedef int _trunc_return_type;
656 #else
657  typedef double_t _trunc_return_type;
658 #endif /* TARGET_RT_MAC_68881 */
659 
668  _trunc_return_type trunc(double_t x);
669 
670  /********************************************************************************
671  * *
672  * Remainder functions *
673  * *
674  * remainder IEEE 754 floating point standard for remainder. * remquo
675  *SANE remainder. It stores into 'quotient' the 7 low-order * bits of the
676  *integer quotient x/y, such that: * -127 <= quotient <= 127. *
677  * *
678  ********************************************************************************/
687  double_t fmod(double_t x, double_t y);
688 
697  double_t remainder(double_t x, double_t y);
698 
707  double_t remquo(double_t x, double_t y, int *quo);
708 
709  /********************************************************************************
710  * *
711  * Auxiliary functions *
712  * *
713  * copysign Produces a value with the magnitude of its first argument *
714  * and sign of its second argument. NOTE: the order of the *
715  * arguments matches the recommendation of the IEEE 754 *
716  * floating point standard, which is opposite from the SANE *
717  * copysign function. *
718  * *
719  * nan The call 'nan("n-char-sequence")' returns a quiet NaN *
720  * with content indicated through tagp in the selected * data
721  *type format. *
722  * *
723  * nextafter Computes the next representable value after 'x' in the *
724  * direction of 'y'. if x == y, then y is returned. *
725  * *
726  ********************************************************************************/
735  double_t copysign(double_t x, double_t y);
736 
745  double nan(const char *tagp);
746 
755  float nanf(const char *tagp);
756 
765  long double nanl(const char *tagp);
766 #if TYPE_LONGDOUBLE_IS_DOUBLE
767 #ifdef __cplusplus
768  inline long double nanl(const char *tagp) { return (long double)nan(tagp); }
769 #else
770 #define nanl(tagp) ((long double)nan(tagp))
771 #endif
772 #endif
773 
782  double nextafterd(double x, double y);
783 
792  float nextafterf(float x, float y);
793 
802  long double nextafterl(long double x, long double y);
803 #if TYPE_LONGDOUBLE_IS_DOUBLE
804 #ifdef __cplusplus
805  inline long double nextafterl(long double x, long double y)
806  {
807  return (long double)nextafterd((double)(x), (double)(y));
808  }
809 #else
810 #define nextafterl(x, y) ((long double)nextafterd((double)(x), (double)(y)))
811 #endif
812 #endif
813 
822  long __fpclassifyd(double x);
823 
832  long __fpclassifyf(float x);
833 
842  long __fpclassify(long double x);
843 #if TYPE_LONGDOUBLE_IS_DOUBLE
844 #ifdef __cplusplus
845  inline long __fpclassify(long double x) { return __fpclassifyd((double)(x)); }
846 #else
847 #define __fpclassify(x) (__fpclassifyd((double)(x)))
848 #endif
849 #endif
850 
859  long __isnormald(double x);
860 
869  long __isnormalf(float x);
870 
879  long __isnormal(long double x);
880 #if TYPE_LONGDOUBLE_IS_DOUBLE
881 #ifdef __cplusplus
882  inline long __isnormal(long double x) { return __isnormald((double)(x)); }
883 #else
884 #define __isnormal(x) (__isnormald((double)(x)))
885 #endif
886 #endif
887 
896  long __isfinited(double x);
897 
906  long __isfinitef(float x);
907 
916  long __isfinite(long double x);
917 #if TYPE_LONGDOUBLE_IS_DOUBLE
918 #ifdef __cplusplus
919  inline long __isfinite(long double x) { return __isfinited((double)(x)); }
920 #else
921 #define __isfinite(x) (__isfinited((double)(x)))
922 #endif
923 #endif
924 
933  long __isnand(double x);
934 
943  long __isnanf(float x);
944 
953  long __isnan(long double x);
954 #if TYPE_LONGDOUBLE_IS_DOUBLE
955 #ifdef __cplusplus
956  inline long __isnan(long double x) { return __isnand((double)(x)); }
957 #else
958 #define __isnan(x) (__isnand((double)(x)))
959 #endif
960 #endif
961 
970  long __signbitd(double x);
971 
980  long __signbitf(float x);
981 
990  long __signbit(long double x);
991 #if TYPE_LONGDOUBLE_IS_DOUBLE
992 #ifdef __cplusplus
993  inline long __signbit(long double x) { return __signbitd((double)(x)); }
994 #else
995 #define __signbit(x) (__signbitd((double)(x)))
996 #endif
997 #endif
998 
1007  double_t __inf(void);
1008 
1009  /********************************************************************************
1010  * *
1011  * Inquiry macros *
1012  * *
1013  * fpclassify Returns one of the FP_� values. * isnormal Non-zero
1014  *if and only if the argument x is normalized. * isfinite Non-zero
1015  *if and only if the argument x is finite. * isnan Non-zero
1016  *if and only if the argument x is a NaN. * signbit Non-zero
1017  *if and only if the sign of the argument x is * negative. This includes,
1018  *NaNs, infinities and zeros. *
1019  * *
1020  ********************************************************************************/
1021  enum
1022  {
1023  FP_SNAN = 0, /* signaling NaN */
1024  FP_QNAN = 1, /* quiet NaN */
1025  FP_INFINITE = 2, /* + or - infinity */
1026  FP_ZERO = 3, /* + or - zero */
1027  FP_NORMAL = 4, /* all normal numbers */
1028  FP_SUBNORMAL = 5 /* denormal numbers */
1029  };
1030 
1031 #define fpclassify(x) \
1032  ((sizeof(x) == sizeof(double)) ? __fpclassifyd(x) \
1033  : (sizeof(x) == sizeof(float)) ? __fpclassifyf(x) \
1034  : __fpclassify(x))
1035 #define isnormal(x) \
1036  ((sizeof(x) == sizeof(double)) ? __isnormald(x) \
1037  : (sizeof(x) == sizeof(float)) ? __isnormalf(x) \
1038  : __isnormal(x))
1039 #define isfinite(x) \
1040  ((sizeof(x) == sizeof(double)) ? __isfinited(x) \
1041  : (sizeof(x) == sizeof(float)) ? __isfinitef(x) \
1042  : __isfinite(x))
1043 #define isnan(x) \
1044  ((sizeof(x) == sizeof(double)) ? __isnand(x) \
1045  : (sizeof(x) == sizeof(float)) ? __isnanf(x) \
1046  : __isnan(x))
1047 #define signbit(x) \
1048  ((sizeof(x) == sizeof(double)) ? __signbitd(x) \
1049  : (sizeof(x) == sizeof(float)) ? __signbitf(x) \
1050  : __signbit(x))
1051 
1052  /********************************************************************************
1053  * *
1054  * Max, Min and Positive Difference *
1055  * *
1056  * fdim Determines the 'positive difference' between its arguments: *
1057  * { x - y, if x > y }, { +0, if x <= y }. If one argument is *
1058  * NaN, then fdim returns that NaN. if both arguments are NaNs, *
1059  * then fdim returns the first argument. *
1060  * *
1061  * fmax Returns the maximum of the two arguments. Corresponds to the *
1062  * max function in FORTRAN. NaN arguments are treated as missing
1063  ** data. If one argument is NaN and the other is a number, then * the number
1064  *is returned. If both are NaNs then the first * argument is returned. *
1065  * *
1066  * fmin Returns the minimum of the two arguments. Corresponds to the *
1067  * min function in FORTRAN. NaN arguments are treated as missing
1068  ** data. If one argument is NaN and the other is a number, then * the number
1069  *is returned. If both are NaNs then the first * argument is returned. *
1070  * *
1071  ********************************************************************************/
1080  double_t fdim(double_t x, double_t y);
1081 
1090  double_t fmax(double_t x, double_t y);
1091 
1100  double_t fmin(double_t x, double_t y);
1101 
1102 #endif /* !defined(__MWERKS__) || !defined(__cmath__) */
1103 
1104  /*******************************************************************************
1105  * Constants *
1106  *******************************************************************************/
1115  extern const double_t pi;
1116 /********************************************************************************
1117  * *
1118  * Non NCEG extensions *
1119  * *
1120  ********************************************************************************/
1121 #ifndef __NOEXTENSIONS__
1122  /********************************************************************************
1123  * *
1124  * Financial functions *
1125  * *
1126  * compound Computes the compound interest factor "(1 + rate)^periods"
1127  ** more accurately than the straightforward computation with * the Power
1128  *function. This is SANE's compound function. *
1129  * *
1130  * annuity Computes the present value factor for an annuity *
1131  * "(1 - (1 + rate)^(-periods)) /rate" more accurately than *
1132  * the straightforward computation with the Power function. *
1133  * This is SANE's annuity function. *
1134  * *
1135  ********************************************************************************/
1144  double_t compound(double_t rate, double_t periods);
1145 
1154  double_t annuity(double_t rate, double_t periods);
1155 
1156  /********************************************************************************
1157  * *
1158  * Random function *
1159  * *
1160  * randomx A pseudorandom number generator. It uses the iteration: *
1161  * (7^5*x)mod(2^31-1) *
1162  * *
1163  ********************************************************************************/
1172  double_t randomx(double_t *x);
1173 
1174  /*******************************************************************************
1175  * Relational operator *
1176  *******************************************************************************/
1177  /* relational operator */
1178  typedef short relop;
1179  enum
1180  {
1181  GREATERTHAN = 0,
1182  LESSTHAN = 1,
1183  EQUALTO = 2,
1184  UNORDERED = 3
1185  };
1186 
1187 #if !defined(__MWERKS__) || !defined(__cmath__)
1196  relop relation(double_t x, double_t y);
1197 
1198 #endif /* !defined(__MWERKS__) || !defined(__cmath__) */
1199 
1200 /********************************************************************************
1201  * *
1202  * Binary to decimal conversions *
1203  * *
1204  * SIGDIGLEN Significant decimal digits. *
1205  * *
1206  * decimal A record which provides an intermediate unpacked form for *
1207  * programmers who wish to do their own parsing of numeric input *
1208  * or formatting of numeric output. *
1209  * *
1210  * decform Controls each conversion to a decimal string. The style field
1211  ** is either FLOATDECIMAL or FIXEDDECIMAL. If FLOATDECIMAL, the * value of
1212  *the field digits is the number of significant digits. * If FIXEDDECIMAL value
1213  *of the field digits is the number of * digits to the right of the decimal
1214  *point. *
1215  * *
1216  * num2dec Converts a double_t to a decimal record using a decform. *
1217  * dec2num Converts a decimal record d to a double_t value. * dec2str
1218  *Converts a decform and decimal to a string using a decform. * str2dec
1219  *Converts a string to a decimal struct. * dec2d
1220  *Similar to dec2num except a double is returned (68k only). * dec2f
1221  *Similar to dec2num except a float is returned. * dec2s
1222  *Similar to dec2num except a short is returned. * dec2l
1223  *Similar to dec2num except a long is returned. *
1224  * *
1225  ********************************************************************************/
1226 #if TARGET_CPU_PPC
1227 #define SIGDIGLEN 36
1228 #elif TARGET_CPU_68K
1229 #define SIGDIGLEN 20
1230 #elif TARGET_CPU_X86
1231 #define SIGDIGLEN 20
1232 #endif
1233 #define DECSTROUTLEN 80 /* max length for dec2str output */
1234 #define FLOATDECIMAL ((char)(0))
1235 #define FIXEDDECIMAL ((char)(1))
1236  struct decimal
1237  {
1238  char sgn; /* sign 0 for +, 1 for - */
1239  char unused;
1240  short exp; /* decimal exponent */
1241  struct
1242  {
1243  unsigned char length;
1244  unsigned char text[SIGDIGLEN]; /* significant digits */
1245  unsigned char unused;
1246  } sig;
1247  };
1248  typedef struct decimal decimal;
1249 
1250  struct decform
1251  {
1252  char style; /* FLOATDECIMAL or FIXEDDECIMAL */
1253  char unused;
1254  short digits;
1255  };
1256  typedef struct decform decform;
1265  void num2dec(const decform *f, double_t x, decimal *d);
1266 
1275  double_t dec2num(const decimal *d);
1276 
1285  void dec2str(const decform *f, const decimal *d, char *s);
1286 
1295  void str2dec(const char *s, short *ix, decimal *d, short *vp);
1296 
1297 #if TARGET_CPU_68K
1298 #if CALL_NOT_IN_CARBON
1307  double dec2d(const decimal *d);
1308 
1309 #endif /* CALL_NOT_IN_CARBON */
1310 
1311 #endif /* TARGET_CPU_68K */
1312 
1321  float dec2f(const decimal *d);
1322 
1331  short dec2s(const decimal *d);
1332 
1341  long dec2l(const decimal *d);
1342 
1343 /********************************************************************************
1344  * *
1345  * 68k-only Transfer Function Prototypes *
1346  * *
1347  ********************************************************************************/
1348 #if TARGET_CPU_68K
1349 #if CALL_NOT_IN_CARBON
1358  void x96tox80(const extended96 *x, extended80 *x80);
1359 
1368  void x80tox96(const extended80 *x80, extended96 *x);
1369 
1370 #endif /* CALL_NOT_IN_CARBON */
1371 
1372 #endif /* TARGET_CPU_68K */
1373 
1374 #endif /* !defined(__NOEXTENSIONS__) */
1375 
1376  /********************************************************************************
1377  * *
1378  * PowerPC-only Function Prototypes *
1379  * *
1380  ********************************************************************************/
1381 
1382 #if TARGET_CPU_PPC
1383 #ifndef __MWERKS__ /* Metrowerks does not support double double */
1384 
1393  long double cosl(long double x);
1394 #if TYPE_LONGDOUBLE_IS_DOUBLE
1395 #ifdef __cplusplus
1396  inline long double cosl(long double x) { return (long double)cos((double)(x)); }
1397 #else
1398 #define cosl(x) ((long double)cos((double)(x)))
1399 #endif
1400 #endif
1401 
1410  long double sinl(long double x);
1411 #if TYPE_LONGDOUBLE_IS_DOUBLE
1412 #ifdef __cplusplus
1413  inline long double sinl(long double x) { return (long double)sin((double)(x)); }
1414 #else
1415 #define sinl(x) ((long double)sin((double)(x)))
1416 #endif
1417 #endif
1418 
1427  long double tanl(long double x);
1428 #if TYPE_LONGDOUBLE_IS_DOUBLE
1429 #ifdef __cplusplus
1430  inline long double tanl(long double x) { return (long double)tan((double)(x)); }
1431 #else
1432 #define tanl(x) ((long double)tan((double)(x)))
1433 #endif
1434 #endif
1435 
1444  long double acosl(long double x);
1445 #if TYPE_LONGDOUBLE_IS_DOUBLE
1446 #ifdef __cplusplus
1447  inline long double acosl(long double x)
1448  {
1449  return (long double)acos((double)(x));
1450  }
1451 #else
1452 #define acosl(x) ((long double)acos((double)(x)))
1453 #endif
1454 #endif
1455 
1464  long double asinl(long double x);
1465 #if TYPE_LONGDOUBLE_IS_DOUBLE
1466 #ifdef __cplusplus
1467  inline long double asinl(long double x)
1468  {
1469  return (long double)asin((double)(x));
1470  }
1471 #else
1472 #define asinl(x) ((long double)asin((double)(x)))
1473 #endif
1474 #endif
1475 
1484  long double atanl(long double x);
1485 #if TYPE_LONGDOUBLE_IS_DOUBLE
1486 #ifdef __cplusplus
1487  inline long double atanl(long double x)
1488  {
1489  return (long double)atan((double)(x));
1490  }
1491 #else
1492 #define atanl(x) ((long double)atan((double)(x)))
1493 #endif
1494 #endif
1495 
1504  long double atan2l(long double y, long double x);
1505 #if TYPE_LONGDOUBLE_IS_DOUBLE
1506 #ifdef __cplusplus
1507  inline long double atan2l(long double y, long double x)
1508  {
1509  return (long double)atan2((double)(y), (double)(x));
1510  }
1511 #else
1512 #define atan2l(y, x) ((long double)atan2((double)(y), (double)(x)))
1513 #endif
1514 #endif
1515 
1524  long double coshl(long double x);
1525 #if TYPE_LONGDOUBLE_IS_DOUBLE
1526 #ifdef __cplusplus
1527  inline long double coshl(long double x)
1528  {
1529  return (long double)cosh((double)(x));
1530  }
1531 #else
1532 #define coshl(x) ((long double)cosh((double)(x)))
1533 #endif
1534 #endif
1535 
1544  long double sinhl(long double x);
1545 #if TYPE_LONGDOUBLE_IS_DOUBLE
1546 #ifdef __cplusplus
1547  inline long double sinhl(long double x)
1548  {
1549  return (long double)sinh((double)(x));
1550  }
1551 #else
1552 #define sinhl(x) ((long double)sinh((double)(x)))
1553 #endif
1554 #endif
1555 
1564  long double tanhl(long double x);
1565 #if TYPE_LONGDOUBLE_IS_DOUBLE
1566 #ifdef __cplusplus
1567  inline long double tanhl(long double x)
1568  {
1569  return (long double)tanh((double)(x));
1570  }
1571 #else
1572 #define tanhl(x) ((long double)tanh((double)(x)))
1573 #endif
1574 #endif
1575 
1584  long double acoshl(long double x);
1585 #if TYPE_LONGDOUBLE_IS_DOUBLE
1586 #ifdef __cplusplus
1587  inline long double acoshl(long double x)
1588  {
1589  return (long double)acosh((double)(x));
1590  }
1591 #else
1592 #define acoshl(x) ((long double)acosh((double)(x)))
1593 #endif
1594 #endif
1595 
1604  long double asinhl(long double x);
1605 #if TYPE_LONGDOUBLE_IS_DOUBLE
1606 #ifdef __cplusplus
1607  inline long double asinhl(long double x)
1608  {
1609  return (long double)asinh((double)(x));
1610  }
1611 #else
1612 #define asinhl(x) ((long double)asinh((double)(x)))
1613 #endif
1614 #endif
1615 
1624  long double atanhl(long double x);
1625 #if TYPE_LONGDOUBLE_IS_DOUBLE
1626 #ifdef __cplusplus
1627  inline long double atanhl(long double x)
1628  {
1629  return (long double)atanh((double)(x));
1630  }
1631 #else
1632 #define atanhl(x) ((long double)atanh((double)(x)))
1633 #endif
1634 #endif
1635 
1644  long double expl(long double x);
1645 #if TYPE_LONGDOUBLE_IS_DOUBLE
1646 #ifdef __cplusplus
1647  inline long double expl(long double x) { return (long double)exp((double)(x)); }
1648 #else
1649 #define expl(x) ((long double)exp((double)(x)))
1650 #endif
1651 #endif
1652 
1661  long double expm1l(long double x);
1662 #if TYPE_LONGDOUBLE_IS_DOUBLE
1663 #ifdef __cplusplus
1664  inline long double expm1l(long double x)
1665  {
1666  return (long double)expm1((double)(x));
1667  }
1668 #else
1669 #define expm1l(x) ((long double)expm1((double)(x)))
1670 #endif
1671 #endif
1672 
1681  long double exp2l(long double x);
1682 #if TYPE_LONGDOUBLE_IS_DOUBLE
1683 #ifdef __cplusplus
1684  inline long double exp2l(long double x)
1685  {
1686  return (long double)exp2((double)(x));
1687  }
1688 #else
1689 #define exp2l(x) ((long double)exp2((double)(x)))
1690 #endif
1691 #endif
1692 
1701  long double frexpl(long double x, int *exponent);
1702 #if TYPE_LONGDOUBLE_IS_DOUBLE
1703 #ifdef __cplusplus
1704  inline long double frexpl(long double x, int *exponent)
1705  {
1706  return (long double)frexp((double)(x), (exponent));
1707  }
1708 #else
1709 #define frexpl(x, exponent) ((long double)frexp((double)(x), (exponent)))
1710 #endif
1711 #endif
1712 
1721  long double ldexpl(long double x, int n);
1722 #if TYPE_LONGDOUBLE_IS_DOUBLE
1723 #ifdef __cplusplus
1724  inline long double ldexpl(long double x, int n)
1725  {
1726  return (long double)ldexp((double)(x), (n));
1727  }
1728 #else
1729 #define ldexpl(x, n) ((long double)ldexp((double)(x), (n)))
1730 #endif
1731 #endif
1732 
1741  long double logl(long double x);
1742 #if TYPE_LONGDOUBLE_IS_DOUBLE
1743 #ifdef __cplusplus
1744  inline long double logl(long double x) { return (long double)log((double)(x)); }
1745 #else
1746 #define logl(x) ((long double)log((double)(x)))
1747 #endif
1748 #endif
1749 
1758  long double log1pl(long double x);
1759 #if TYPE_LONGDOUBLE_IS_DOUBLE
1760 #ifdef __cplusplus
1761  inline long double log1pl(long double x)
1762  {
1763  return (long double)log1p((double)(x));
1764  }
1765 #else
1766 #define log1pl(x) ((long double)log1p((double)(x)))
1767 #endif
1768 #endif
1769 
1778  long double log10l(long double x);
1779 #if TYPE_LONGDOUBLE_IS_DOUBLE
1780 #ifdef __cplusplus
1781  inline long double log10l(long double x)
1782  {
1783  return (long double)log10((double)(x));
1784  }
1785 #else
1786 #define log10l(x) ((long double)log10((double)(x)))
1787 #endif
1788 #endif
1789 
1798  long double log2l(long double x);
1799 #if TYPE_LONGDOUBLE_IS_DOUBLE
1800 #ifdef __cplusplus
1801  inline long double log2l(long double x)
1802  {
1803  return (long double)log2((double)(x));
1804  }
1805 #else
1806 #define log2l(x) ((long double)log2((double)(x)))
1807 #endif
1808 #endif
1809 
1818  long double logbl(long double x);
1819 #if TYPE_LONGDOUBLE_IS_DOUBLE
1820 #ifdef __cplusplus
1821  inline long double logbl(long double x)
1822  {
1823  return (long double)logb((double)(x));
1824  }
1825 #else
1826 #define logbl(x) ((long double)logb((double)(x)))
1827 #endif
1828 #endif
1829 
1838  long double scalbl(long double x, long n);
1839 #if TYPE_LONGDOUBLE_IS_DOUBLE
1840 #ifdef __cplusplus
1841  inline long double scalbl(long double x, long n)
1842  {
1843  return (long double)scalb((double)(x), (n));
1844  }
1845 #else
1846 #define scalbl(x, n) ((long double)scalb((double)(x), (n)))
1847 #endif
1848 #endif
1849 
1858  long double fabsl(long double x);
1859 #if TYPE_LONGDOUBLE_IS_DOUBLE
1860 #ifdef __cplusplus
1861  inline long double fabsl(long double x)
1862  {
1863  return (long double)fabs((double)(x));
1864  }
1865 #else
1866 #define fabsl(x) ((long double)fabs((double)(x)))
1867 #endif
1868 #endif
1869 
1878  long double hypotl(long double x, long double y);
1879 #if TYPE_LONGDOUBLE_IS_DOUBLE
1880 #ifdef __cplusplus
1881  inline long double hypotl(long double x, long double y)
1882  {
1883  return (long double)hypot((double)(x), (double)(y));
1884  }
1885 #else
1886 #define hypotl(x, y) ((long double)hypot((double)(x), (double)(y)))
1887 #endif
1888 #endif
1889 
1898  long double powl(long double x, long double y);
1899 #if TYPE_LONGDOUBLE_IS_DOUBLE
1900 #ifdef __cplusplus
1901  inline long double powl(long double x, long double y)
1902  {
1903  return (long double)pow((double)(x), (double)(y));
1904  }
1905 #else
1906 #define powl(x, y) ((long double)pow((double)(x), (double)(y)))
1907 #endif
1908 #endif
1909 
1918  long double sqrtl(long double x);
1919 #if TYPE_LONGDOUBLE_IS_DOUBLE
1920 #ifdef __cplusplus
1921  inline long double sqrtl(long double x)
1922  {
1923  return (long double)sqrt((double)(x));
1924  }
1925 #else
1926 #define sqrtl(x) ((long double)sqrt((double)(x)))
1927 #endif
1928 #endif
1929 
1938  long double erfl(long double x);
1939 #if TYPE_LONGDOUBLE_IS_DOUBLE
1940 #ifdef __cplusplus
1941  inline long double erfl(long double x) { return (long double)erf((double)(x)); }
1942 #else
1943 #define erfl(x) ((long double)erf((double)(x)))
1944 #endif
1945 #endif
1946 
1955  long double erfcl(long double x);
1956 #if TYPE_LONGDOUBLE_IS_DOUBLE
1957 #ifdef __cplusplus
1958  inline long double erfcl(long double x)
1959  {
1960  return (long double)erfc((double)(x));
1961  }
1962 #else
1963 #define erfcl(x) ((long double)erfc((double)(x)))
1964 #endif
1965 #endif
1966 
1975  long double gammal(long double x);
1976 #if TYPE_LONGDOUBLE_IS_DOUBLE
1977 #ifdef __cplusplus
1978  inline long double gammal(long double x)
1979  {
1980  return (long double)gamma((double)(x));
1981  }
1982 #else
1983 #define gammal(x) ((long double)gamma((double)(x)))
1984 #endif
1985 #endif
1986 
1995  long double lgammal(long double x);
1996 #if TYPE_LONGDOUBLE_IS_DOUBLE
1997 #ifdef __cplusplus
1998  inline long double lgammal(long double x)
1999  {
2000  return (long double)lgamma((double)(x));
2001  }
2002 #else
2003 #define lgammal(x) ((long double)lgamma((double)(x)))
2004 #endif
2005 #endif
2006 
2015  long double ceill(long double x);
2016 #if TYPE_LONGDOUBLE_IS_DOUBLE
2017 #ifdef __cplusplus
2018  inline long double ceill(long double x)
2019  {
2020  return (long double)ceil((double)(x));
2021  }
2022 #else
2023 #define ceill(x) ((long double)ceil((double)(x)))
2024 #endif
2025 #endif
2026 
2035  long double floorl(long double x);
2036 #if TYPE_LONGDOUBLE_IS_DOUBLE
2037 #ifdef __cplusplus
2038  inline long double floorl(long double x)
2039  {
2040  return (long double)floor((double)(x));
2041  }
2042 #else
2043 #define floorl(x) ((long double)floor((double)(x)))
2044 #endif
2045 #endif
2046 
2055  long double rintl(long double x);
2056 #if TYPE_LONGDOUBLE_IS_DOUBLE
2057 #ifdef __cplusplus
2058  inline long double rintl(long double x)
2059  {
2060  return (long double)rint((double)(x));
2061  }
2062 #else
2063 #define rintl(x) ((long double)rint((double)(x)))
2064 #endif
2065 #endif
2066 
2075  long double nearbyintl(long double x);
2076 #if TYPE_LONGDOUBLE_IS_DOUBLE
2077 #ifdef __cplusplus
2078  inline long double nearbyintl(long double x)
2079  {
2080  return (long double)nearbyint((double)(x));
2081  }
2082 #else
2083 #define nearbyintl(x) ((long double)nearbyint((double)(x)))
2084 #endif
2085 #endif
2086 
2095  long rinttoll(long double x);
2096 #if TYPE_LONGDOUBLE_IS_DOUBLE
2097 #ifdef __cplusplus
2098  inline long rinttoll(long double x) { return rinttol((double)(x)); }
2099 #else
2100 #define rinttoll(x) (rinttol((double)(x)))
2101 #endif
2102 #endif
2103 
2112  long double roundl(long double x);
2113 #if TYPE_LONGDOUBLE_IS_DOUBLE
2114 #ifdef __cplusplus
2115  inline long double roundl(long double x)
2116  {
2117  return (long double)round((double)(x));
2118  }
2119 #else
2120 #define roundl(x) ((long double)round((double)(x)))
2121 #endif
2122 #endif
2123 
2132  long roundtoll(long double x);
2133 #if TYPE_LONGDOUBLE_IS_DOUBLE
2134 #ifdef __cplusplus
2135  inline long roundtoll(long double x) { return roundtol((double)(x)); }
2136 #else
2137 #define roundtoll(x) (roundtol((double)(x)))
2138 #endif
2139 #endif
2140 
2149  long double truncl(long double x);
2150 #if TYPE_LONGDOUBLE_IS_DOUBLE
2151 #ifdef __cplusplus
2152  inline long double truncl(long double x)
2153  {
2154  return (long double)trunc((double)(x));
2155  }
2156 #else
2157 #define truncl(x) ((long double)trunc((double)(x)))
2158 #endif
2159 #endif
2160 
2169  long double remainderl(long double x, long double y);
2170 #if TYPE_LONGDOUBLE_IS_DOUBLE
2171 #ifdef __cplusplus
2172  inline long double remainderl(long double x, long double y)
2173  {
2174  return (long double)remainder((double)(x), (double)(y));
2175  }
2176 #else
2177 #define remainderl(x, y) ((long double)remainder((double)(x), (double)(y)))
2178 #endif
2179 #endif
2180 
2189  long double remquol(long double x, long double y, int *quo);
2190 #if TYPE_LONGDOUBLE_IS_DOUBLE
2191 #ifdef __cplusplus
2192  inline long double remquol(long double x, long double y, int *quo)
2193  {
2194  return (long double)remquo((double)(x), (double)(y), (quo));
2195  }
2196 #else
2197 #define remquol(x, y, quo) \
2198  ((long double)remquo((double)(x), (double)(y), (quo)))
2199 #endif
2200 #endif
2201 
2210  long double copysignl(long double x, long double y);
2211 #if TYPE_LONGDOUBLE_IS_DOUBLE
2212 #ifdef __cplusplus
2213  inline long double copysignl(long double x, long double y)
2214  {
2215  return (long double)copysign((double)(x), (double)(y));
2216  }
2217 #else
2218 #define copysignl(x, y) ((long double)copysign((double)(x), (double)(y)))
2219 #endif
2220 #endif
2221 
2230  long double fdiml(long double x, long double y);
2231 #if TYPE_LONGDOUBLE_IS_DOUBLE
2232 #ifdef __cplusplus
2233  inline long double fdiml(long double x, long double y)
2234  {
2235  return (long double)fdim((double)(x), (double)(y));
2236  }
2237 #else
2238 #define fdiml(x, y) ((long double)fdim((double)(x), (double)(y)))
2239 #endif
2240 #endif
2241 
2250  long double fmaxl(long double x, long double y);
2251 #if TYPE_LONGDOUBLE_IS_DOUBLE
2252 #ifdef __cplusplus
2253  inline long double fmaxl(long double x, long double y)
2254  {
2255  return (long double)fmax((double)(x), (double)(y));
2256  }
2257 #else
2258 #define fmaxl(x, y) ((long double)fmax((double)(x), (double)(y)))
2259 #endif
2260 #endif
2261 
2270  long double fminl(long double x, long double y);
2271 #if TYPE_LONGDOUBLE_IS_DOUBLE
2272 #ifdef __cplusplus
2273  inline long double fminl(long double x, long double y)
2274  {
2275  return (long double)fmin((double)(x), (double)(y));
2276  }
2277 #else
2278 #define fminl(x, y) ((long double)fmin((double)(x), (double)(y)))
2279 #endif
2280 #endif
2281 
2282 #endif /* __MWERKS__ */
2283 #ifndef __NOEXTENSIONS__
2292  relop relationl(long double x, long double y);
2293 #if TYPE_LONGDOUBLE_IS_DOUBLE
2294 #ifdef __cplusplus
2295  inline relop relationl(long double x, long double y)
2296  {
2297  return relation((double)(x), (double)(y));
2298  }
2299 #else
2300 #define relationl(x, y) (relation((double)(x), (double)(y)))
2301 #endif
2302 #endif
2303 
2312  void num2decl(const decform *f, long double x, decimal *d);
2313 #if TYPE_LONGDOUBLE_IS_DOUBLE
2314 #ifdef __cplusplus
2315  inline void num2decl(const decform *f, long double x, decimal *d)
2316  {
2317  num2dec((f), (double)(x), (d));
2318  }
2319 #else
2320 #define num2decl(f, x, d) (num2dec((f), (double)(x), (d)))
2321 #endif
2322 #endif
2323 
2332  long double dec2numl(const decimal *d);
2333 #if TYPE_LONGDOUBLE_IS_DOUBLE
2334 #ifdef __cplusplus
2335  inline long double dec2numl(const decimal *d)
2336  {
2337  return (long double)dec2num(d);
2338  }
2339 #else
2340 #define dec2numl(d) ((long double)dec2num(d))
2341 #endif
2342 #endif
2343 
2344 #endif /* !defined(__NOEXTENSIONS__) */
2345 
2346 #endif /* TARGET_CPU_PPC */
2347 
2348 #endif /* TARGET_OS_MAC */
2349 
2350 #ifndef __NOEXTENSIONS__
2365  double x80tod(const extended80 *x80);
2366 
2375  void dtox80(const double *x, extended80 *x80);
2376 
2385  void x80told(const extended80 *x80, long double *x);
2386 #if TYPE_LONGDOUBLE_IS_DOUBLE
2387 #ifdef __cplusplus
2388  inline void x80told(const extended80 *x80, long double *x)
2389  {
2390  *(x) = (long double)x80tod(x80);
2391  }
2392 #else
2393 #define x80told(x80, x) (*(x) = (long double)x80tod(x80))
2394 #endif
2395 #endif
2396 
2405  void ldtox80(const long double *x, extended80 *x80);
2406 #if TYPE_LONGDOUBLE_IS_DOUBLE
2407 #ifdef __cplusplus
2408  inline void ldtox80(const long double *x, extended80 *x80)
2409  {
2410  double d = (double)*(x);
2411  dtox80(&d, (x80));
2412  }
2413 #else
2414 #define ldtox80(x, x80) \
2415  do \
2416  { \
2417  double d = (double)*(x); \
2418  dtox80(&d, (x80)); \
2419  } while (false)
2420 #endif
2421 #endif
2422 
2423 #endif /* !defined(__NOEXTENSIONS__) */
2424 
2425 #if PRAGMA_STRUCT_ALIGN
2426 #pragma options align = reset
2427 #elif PRAGMA_STRUCT_PACKPUSH
2428 #pragma pack(pop)
2429 #elif PRAGMA_STRUCT_PACK
2430 #pragma pack()
2431 #endif
2432 
2433 #ifdef PRAGMA_IMPORT_OFF
2434 #pragma import off
2435 #elif PRAGMA_IMPORT
2436 #pragma import reset
2437 #endif
2438 
2439 #ifdef __cplusplus
2440 }
2441 #endif
2442 
2443 #endif /* __FP__ */
Set up for compiler independent conditionals.
Basic Macintosh data types.
x
Definition: ToolUtils.h:163
void ldtox80(const long double *x, extended80 *x80)
void x80told(const extended80 *x80, long double *x)
void dtox80(const double *x, extended80 *x80)
double x80tod(const extended80 *x80)
Definition: MacTypes.h:206
Definition: MacTypes.h:213