mirror of
https://github.com/byteworksinc/ORCA-C.git
synced 2024-12-30 14:31:04 +00:00
Add documentation and headers for new <math.h> functions.
This commit is contained in:
parent
aaec648e69
commit
6fa294aa3b
@ -63,7 +63,7 @@ int __fpcompare(long double, long double, short);
|
||||
#define isunordered(x,y) __fpcompare((x),(y),0x01)
|
||||
|
||||
#ifndef __KeepNamespacePure__
|
||||
#define arctan(x) atan(x)
|
||||
#define arctan(x) atan(x)
|
||||
#endif
|
||||
|
||||
double acos(double);
|
||||
@ -105,9 +105,18 @@ long double expm1l(long double);
|
||||
double fabs(double);
|
||||
float fabsf(float);
|
||||
long double fabsl(long double);
|
||||
double fdim(double, double);
|
||||
float fdimf(float, float);
|
||||
long double fdiml(long double, long double);
|
||||
double floor(double);
|
||||
float floorf(float);
|
||||
long double floorl(long double);
|
||||
double fmax(double, double);
|
||||
float fmaxf(float, float);
|
||||
long double fmaxl(long double, long double);
|
||||
double fmin(double, double);
|
||||
float fminf(float, float);
|
||||
long double fminl(long double, long double);
|
||||
double fmod(double, double);
|
||||
float fmodf(float, float);
|
||||
long double fmodl(long double, long double);
|
||||
@ -120,6 +129,14 @@ int ilogbl(long double);
|
||||
double ldexp(double, int);
|
||||
float ldexpf(float, int);
|
||||
long double ldexpl(long double, int);
|
||||
#if defined(__ORCAC_HAS_LONG_LONG__) || __STDC_VERSION__ >= 199901L
|
||||
long long llrint(double);
|
||||
long long llrintf(float);
|
||||
long long llrintl(long double);
|
||||
long long llround(double);
|
||||
long long llroundf(float);
|
||||
long long llroundl(long double);
|
||||
#endif
|
||||
double log(double);
|
||||
float logf(float);
|
||||
long double logl(long double);
|
||||
@ -138,9 +155,24 @@ long double logbl(long double);
|
||||
long lrint(double);
|
||||
long lrintf(float);
|
||||
long lrintl(long double);
|
||||
long lround(double);
|
||||
long lroundf(float);
|
||||
long lroundl(long double);
|
||||
double modf(double, double *);
|
||||
float modff(float, float *);
|
||||
long double modfl(long double, long double *);
|
||||
double nearbyint(double);
|
||||
float nearbyintf(float);
|
||||
long double nearbyintl(long double);
|
||||
double nan(const char *);
|
||||
float nanf(const char *);
|
||||
long double nanl(const char *);
|
||||
double nextafter(double, double);
|
||||
float nextafterf(float, float);
|
||||
long double nextafterl(long double, long double);
|
||||
double nexttoward(double, long double);
|
||||
float nexttowardf(float, long double);
|
||||
long double nexttowardl(long double, long double);
|
||||
double pow(double, double);
|
||||
float powf(float, float);
|
||||
long double powl(long double, long double);
|
||||
@ -153,6 +185,12 @@ long double remquol(long double, long double, int *);
|
||||
double rint(double);
|
||||
float rintf(float);
|
||||
long double rintl(long double);
|
||||
double round(double);
|
||||
float roundf(float);
|
||||
long double roundl(long double);
|
||||
double scalbln(double, long);
|
||||
float scalblnf(float, long);
|
||||
long double scalblnl(long double, long);
|
||||
double scalbn(double, int);
|
||||
float scalbnf(float, int);
|
||||
long double scalbnl(long double, int);
|
||||
@ -173,6 +211,6 @@ float tanhf(float);
|
||||
long double tanhl(long double);
|
||||
double trunc(double);
|
||||
float truncf(float);
|
||||
long double truncl(long double);
|
||||
long double truncl(long double);
|
||||
|
||||
#endif
|
||||
|
@ -48,22 +48,33 @@
|
||||
#define exp2(x) __tg_real_x(exp2,(x))
|
||||
#define expm1(x) __tg_real_x(expm1,(x))
|
||||
#define fabs(x) __tg_real_x(fabs,(x))
|
||||
#define fdim(x,y) __tg_real_x_y(fdim,(x),(y))
|
||||
#define fmax(x,y) __tg_real_x_y(fmax,(x),(y))
|
||||
#define fmin(x,y) __tg_real_x_y(fmin,(x),(y))
|
||||
#define floor(x) __tg_real_x(floor,(x))
|
||||
#define fmod(x,y) __tg_real_x_y(fmod,(x),(y))
|
||||
#define frexp(x,nptr) __tg_real_x_other(frexp,(x),(nptr))
|
||||
#define ilogb(x) __tg_real_x(ilogb,(x))
|
||||
#define ldexp(x,n) __tg_real_x_other(ldexp,(x),(n))
|
||||
#define llrint(x) __tg_real_x(llrint,(x))
|
||||
#define llround(x) __tg_real_x(llround,(x))
|
||||
#define log(x) __tg_x(log,(x))
|
||||
#define log10(x) __tg_real_x(log10,(x))
|
||||
#define log1p(x) __tg_real_x(log1p,(x))
|
||||
#define log2(x) __tg_real_x(log2,(x))
|
||||
#define logb(x) __tg_real_x(logb,(x))
|
||||
#define lrint(x) __tg_real_x(lrint,(x))
|
||||
#define lround(x) __tg_real_x(lround,(x))
|
||||
#define nearbyint(x) __tg_real_x(nearbyint,(x))
|
||||
#define nextafter(x,y) __tg_real_x_y(nextafter,(x),(y))
|
||||
#define nexttoward(x,y) __tg_real_x_y(nexttoward,(x),(y))
|
||||
#define pow(x,y) __tg_x_y(pow,(x),(y))
|
||||
#define remainder(x,y) __tg_real_x_y(remainder,(x),(y))
|
||||
#define remquo(x,y,quo) __tg_real_x_y_other(remquo,(x),(y),(quo))
|
||||
#define rint(x) __tg_real_x(rint,(x))
|
||||
#define round(x) __tg_real_x(round,(x))
|
||||
#define scalbn(x,n) __tg_real_x_other(scalbn,(x),(n))
|
||||
#define scalbln(x,n) __tg_real_x_other(scalbln,(x),(n))
|
||||
#define sin(x) __tg_x(sin,(x))
|
||||
#define sinh(x) __tg_x(sinh,(x))
|
||||
#define sqrt(x) __tg_x(sqrt,(x))
|
||||
|
79
cc.notes
79
cc.notes
@ -31,8 +31,8 @@ Updated by Stephen Heumann and Kelvin Sherlock, 2017-2021
|
||||
|
||||
10. Stack repair code is now more efficient.
|
||||
|
||||
11. Some new library functions and features from C99 and C11 have
|
||||
been added. See "Library Updates."
|
||||
11. Several new library functions and features from C99 and C11
|
||||
have been added. See "Library Updates."
|
||||
|
||||
12. Floating-point constant expressions now use extended precision.
|
||||
See "Evaluation of Floating-Point Expressions and Constants."
|
||||
@ -875,7 +875,7 @@ int isunordered(real-floating x, real-floating y);
|
||||
|
||||
These macros accept arguments of any real floating types, i.e. float, double, or long double. They return 1 if x and y have the indicated relationship, or 0 if they do not. These macros differ from the ordinary relational operators in that the macros will not raise the "invalid" floating-point exception if x and y are unordered because one or both is a quiet NaN. (In ORCA/C, they will raise the "invalid" exception for signaling NaNs.)
|
||||
|
||||
19. (C99) Several new functions operating on floating-point values have been added. Each of these has a version using each of the three real floating types (float, double, and long double) for its arguments and/or return values, as shown below. Under ORCA/C, however, these types are all passed and returned using the SANE extended format (the format of long double), and for most of these functions the three versions will actually behave identically.
|
||||
19. (C99) Several new functions operating on floating-point values have been added. Each of these has a version using each of the three real floating types (float, double, and long double) for its arguments and/or return values. The double versions have no suffix, while the float and long double versions have an 'f' or 'l' suffix. Under ORCA/C, however, these types are all passed and returned using the SANE extended format (the format of long double), and for most of these functions the three versions will actually behave identically.
|
||||
|
||||
Also, note that under ORCA/C these functions generally will not set errno for error conditions (e.g. domain and range errors). However, they do set floating-point exceptions as appropriate. The <fenv.h> functions documented above can be used to retrieve these exceptions, allowing errors to be detected.
|
||||
|
||||
@ -907,6 +907,25 @@ long double expm1l(long double x);
|
||||
|
||||
These functions return e^x - 1.
|
||||
|
||||
#include <math.h>
|
||||
double fdim(double x, double y);
|
||||
float fdimf(float x, float y);
|
||||
long double fdiml(long double x, long double y);
|
||||
|
||||
These functions return x - y if x > y, or +0.0 if x <= y.
|
||||
|
||||
double fmax(double x, double y);
|
||||
float fmaxf(float x, float y);
|
||||
long double fmaxl(long double x, long double y);
|
||||
|
||||
These functions return the maximum numeric value of their arguments. If one argument is a NaN, the other argument is returned.
|
||||
|
||||
double fmin(double x, double y);
|
||||
float fminf(float x, float y);
|
||||
long double fminl(long double x, long double y);
|
||||
|
||||
These functions return the minimum numeric value of their arguments. If one argument is a NaN, the other argument is returned.
|
||||
|
||||
#include <math.h>
|
||||
int ilogb(double x);
|
||||
int ilogbf(float x);
|
||||
@ -939,8 +958,37 @@ These functions extract the binary exponent of x as an integer value in floating
|
||||
long lrint(double x);
|
||||
long lrintf(float x);
|
||||
long lrintl(long double x);
|
||||
long long llrint(double x);
|
||||
long long llrintf(float x);
|
||||
long long llrintl(long double x);
|
||||
|
||||
These functions round x to an integer using the current rounding direction and return it as a long. If the value is outside the range of the return type, the number returned is unspecified.
|
||||
These functions round x to an integer using the current rounding direction and return it as a long or long long. If the rounded value is outside the range of the return type, the number returned is unspecified.
|
||||
|
||||
#include <math.h>
|
||||
long lround(double x);
|
||||
long lroundf(float x);
|
||||
long lroundl(long double x);
|
||||
long long llround(double x);
|
||||
long long llroundf(float x);
|
||||
long long llroundl(long double x);
|
||||
|
||||
These functions round x to the nearest integer, rounding halfway cases away from zero, regardless of the current rounding direction. They then return the rounded value as a long or long long. If the rounded value is outside the range of the return type, the number returned is unspecified.
|
||||
|
||||
double nan(const char *tagp);
|
||||
float nanf(const char *tagp);
|
||||
long double nanl(const char *tagp);
|
||||
|
||||
These functions return a quiet NaN, with the NaN code determined by the string argument. Specifically, nan("char-sequence") returns the same value as strtod("NAN(char-sequence)", NULL). See the Apple Numerics Manual for a description of NaN codes.
|
||||
|
||||
#include <math.h>
|
||||
double nextafter(double x, double y);
|
||||
float nextafterf(float x, float y);
|
||||
long double nextafterl(long double x, long double y);
|
||||
double nexttoward(double x, long double y);
|
||||
float nexttowardf(float x, long double y);
|
||||
long double nexttowardl(long double x, long double y);
|
||||
|
||||
These functions first convert x and y to their declared types (removing any extra range and precision), then they return the next representable value (in the return type of the function) after x in the direction of y. If x equals y, they return y. The only difference between the nextafter and nexttoward functions is the type of y; nextafterl and nexttowardl are identical.
|
||||
|
||||
#include <math.h>
|
||||
double remainder(double x, double y);
|
||||
@ -956,13 +1004,26 @@ These functions return x REM y as specified by IEEE 754: r = x - ny, where n is
|
||||
double rint(double x);
|
||||
float rintf(float x);
|
||||
long double rintl(long double x);
|
||||
double nearbyint(double x);
|
||||
float nearbyintf(float x);
|
||||
long double nearbyintl(long double x);
|
||||
|
||||
These functions round x to an integer using the current rounding direction.
|
||||
These functions round x to an integer using the current rounding direction. The rint functions raise the "inexact" floating-point exception if they change the value, while the nearbyint functions do not.
|
||||
|
||||
#include <math.h>
|
||||
double round(double x);
|
||||
float roundf(float x);
|
||||
long double roundl(long double x);
|
||||
|
||||
These functions round x to the nearest integer, rounding halfway cases away from zero, regardless of the current rounding direction.
|
||||
|
||||
#include <math.h>
|
||||
double scalbn(double x, int n);
|
||||
float scalbnf(float x, int n);
|
||||
long double scalbnl(long double x, int n);
|
||||
double scalbln(double x, long n);
|
||||
float scalblnf(float x, long n);
|
||||
long double scalblnl(long double x, long n);
|
||||
|
||||
These functions return x * FLT_RADIX^n, computed efficiently. In ORCA/C, FLT_RADIX is 2.
|
||||
|
||||
@ -973,7 +1034,7 @@ long double truncl(long double x);
|
||||
|
||||
These functions truncate x to an integer (discarding the fractional part).
|
||||
|
||||
There are also added functions that correspond to existing <math.h> functions, but using float or long double for their argument and return types. In ORCA/C, most of these actually behave identically to the existing un-suffixed versions. An exception is the modf family of functions, which differ in the type of the location in which the integer part of the value is stored.
|
||||
There are also added functions that correspond to existing <math.h> functions, but using float or long double for their argument and return types:
|
||||
|
||||
#include <math.h>
|
||||
float acosf(float x);
|
||||
@ -1021,12 +1082,16 @@ long double tanl(long double x);
|
||||
float tanhf(float x);
|
||||
long double tanhl(long double x);
|
||||
|
||||
Similarly, there are float and long double analogs of the string conversion function strtod. As currently implemented in ORCA/C, all of these functions behave identically, giving values with the precision and range of long double.
|
||||
These functions are equivalent to the existing un-suffixed versions, apart from their argument and return types. In ORCA/C, most of them actually behave identically to the un-suffixed versions. An exception is the modf family of functions, which differ in the type of the location in which the integer part of the value is stored.
|
||||
|
||||
Similarly, there are float and long double analogs of the string conversion function strtod:
|
||||
|
||||
#include <stdlib.h>
|
||||
float strtof(const char * restrict str, char ** restrict ptr);
|
||||
long double strtold(const char * restrict str, char ** restrict ptr);
|
||||
|
||||
As currently implemented in ORCA/C, strtof and strtold behave identically to strtod, all giving values with the precision and range of long double.
|
||||
|
||||
-- Compiler changes introduced in C 2.1.0 -----------------------------------
|
||||
|
||||
The Default .h File
|
||||
|
Loading…
Reference in New Issue
Block a user