Errors in math function man pages

Brian Inglis Brian.Inglis@SystematicSw.ab.ca
Wed Dec 29 05:10:00 GMT 2021


On 2021-12-28 18:57, Keith Thompson wrote:
> There are two errors in the sqrt(3) man page, with similar errors in
> the man pages for most or all of the other math functions specified
> in <math.h>.  The math functions are implemented correctly as far as
> I can tell, but the man pages are out of date, reflecting the language
> as of the 1989 ANSI / 1999 ISO C standard.
> 
> C89/C90 defined math functions only for type double, but C99 and
> later added corresponding functions for float and long double (with
> 'f' and 'l' suffixes), and also introduced a number of new functions.
> 
> Using sqrt(3) man page as an example, it mentions sqrt and sqrtf,
> but does not mention sqrtl.
> 
> Second, it says:
> 
>> sqrt is ANSI C.  sqrtf is an extension.
> 
> That was true as of C89/C89, but sqrt, sqrtf, and sqrtl are all defined
> by ISO C 1999 and later.  (And I suggest referring to "ISO C" rather
> than the ambiguous "ANSI C".)
> 
> The same problem appears in most or all of the man pages for functions
> declared in <math.h>.
> 
> Another example: the man page for asinh (inverse hyperbolic sine) says:
>> Neither asinh nor asinhf are ANSI C.
> 
> As of C99 and later, asinh, asinhf, and asinhl are all ISO C.
> 
> I *think* this is the list of source files that would need to corrected
> to bring the man pages up to date:
> 
> newlib/libm/math/s_asinh.c
> newlib/libm/math/s_atan.c
> newlib/libm/math/s_erf.c
> newlib/libm/math/s_sin.c
> newlib/libm/math/s_tanh.c
> newlib/libm/math/w_acosh.c
> newlib/libm/math/w_atan2.c
> newlib/libm/math/w_atanh.c
> newlib/libm/math/w_exp.c
> newlib/libm/math/w_fmod.c
> newlib/libm/math/w_gamma.c
> newlib/libm/math/w_hypot.c
> newlib/libm/math/w_log10.c
> newlib/libm/math/w_pow.c
> newlib/libm/math/w_sinh.c
> newlib/libm/math/w_sqrt.c
> newlib/libm/mathfp/e_acosh.c
> newlib/libm/mathfp/e_atanh.c
> newlib/libm/mathfp/e_hypot.c
> newlib/libm/mathfp/er_lgamma.c
> newlib/libm/mathfp/s_asinh.c
> newlib/libm/mathfp/s_atan.c
> newlib/libm/mathfp/s_atan2.c
> newlib/libm/mathfp/s_atangent.c
> newlib/libm/mathfp/s_erf.c
> newlib/libm/mathfp/s_exp.c
> newlib/libm/mathfp/s_fmod.c
> newlib/libm/mathfp/s_log10.c
> newlib/libm/mathfp/s_pow.c
> newlib/libm/mathfp/s_sine.c
> newlib/libm/mathfp/s_sineh.c
> newlib/libm/mathfp/s_sqrt.c
> newlib/libm/mathfp/s_tanh.c

Attached is a list of what should be the C2017 math functions and macros 
derived from an early draft of C202X with no changes in that section, 
which should allow it to be quoted and used without issues.

For more details, there is also:
https://en.cppreference.com/w/c/numeric/math

-- 
Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada

This email may be disturbing to some readers as it contains
too much technical detail. Reader discretion is advised.
[Data in binary units and prefixes, physical quantities in SI.]
-------------- next part --------------
7.12.1		Treatment of error conditions

7.12.2		The FP_CONTRACT pragma
Synopsis
	#include <math.h>
	#pragma STDC FP_CONTRACT on-off-switch

7.12.3		Classification macros

7.12.3.1 The fpclassify macro
Synopsis
	#include <math.h>
	int fpclassify(real-floating x);

7.12.3.2 The isfinite macro
Synopsis
	#include <math.h>
	int isfinite(real-floating x);

7.12.3.3 The isinf macro
Synopsis
	#include <math.h>
	int isinf(real-floating x);

7.12.3.4 The isnan macro
Synopsis
	#include <math.h>
	int isnan(real-floating x);

7.12.3.5 The isnormal macro
Synopsis
	#include <math.h>
	int isnormal(real-floating x);

7.12.3.6 The signbit macro
Synopsis
	#include <math.h>
	int signbit(real-floating x);

7.12.4		Trigonometric functions

7.12.4.1 The acos functions
Synopsis
	#include <math.h>
	double acos(double x);
	float acosf(float x);
	long double acosl(long double x);

7.12.4.2 The asin functions
Synopsis
	#include <math.h>
	double asin(double x);
	float asinf(float x);
	long double asinl(long double x);

7.12.4.3 The atan functions
Synopsis
	#include <math.h>
	double atan(double x);
	float atanf(float x);
	long double atanl(long double x);

7.12.4.4 The atan2 functions
Synopsis
	#include <math.h>
	double atan2(double y, double x);
	float atan2f(float y, float x);
	long double atan2l(long double y, long double x);

7.12.4.5 The cos functions
Synopsis
	#include <math.h>
	double cos(double x);
	float cosf(float x);
	long double cosl(long double x);

7.12.4.6 The sin functions
Synopsis
	#include <math.h>
	double sin(double x);
	float sinf(float x);
	long double sinl(long double x);

7.12.4.7 The tan functions
Synopsis
	#include <math.h>
	double tan(double x);
	float tanf(float x);
	long double tanl(long double x);

7.12.5		Hyperbolic functions

7.12.5.1 The acosh functions
Synopsis
	#include <math.h>
	double acosh(double x);
	float acoshf(float x);
	long double acoshl(long double x);

7.12.5.2 The asinh functions
Synopsis
	#include <math.h>
	double asinh(double x);
	float asinhf(float x);
	long double asinhl(long double x);

7.12.5.3 The atanh functions
Synopsis
	#include <math.h>
	double atanh(double x);
	float atanhf(float x);
	long double atanhl(long double x);

7.12.5.4 The cosh functions
Synopsis
	#include <math.h>
	double cosh(double x);
	float coshf(float x);
	long double coshl(long double x);

7.12.5.5 The sinh functions
Synopsis
	#include <math.h>
	double sinh(double x);
	float sinhf(float x);
	long double sinhl(long double x);

7.12.5.6 The tanh functions
Synopsis
	#include <math.h>
	double tanh(double x);
	float tanhf(float x);
	long double tanhl(long double x);

7.12.6		Exponential and logarithmic functions

7.12.6.1 The exp functions
Synopsis
	#include <math.h>
	double exp(double x);
	float expf(float x);
	long double expl(long double x);

7.12.6.2 The exp2 functions
Synopsis
	#include <math.h>
	double exp2(double x);
	float exp2f(float x);
	long double exp2l(long double x);

7.12.6.3 The expm1 functions
Synopsis
	#include <math.h>
	double expm1(double x);
	float expm1f(float x);
	long double expm1l(long double x);

7.12.6.4 The frexp functions
Synopsis
	#include <math.h>
	double frexp(double value, int *exp);
	float frexpf(float value, int *exp);
	long double frexpl(long double value, int *exp);

7.12.6.5 The ilogb functions
Synopsis
	#include <math.h>
	int ilogb(double x);
	int ilogbf(float x);
	int ilogbl(long double x);

7.12.6.6 The ldexp functions
Synopsis
	#include <math.h>
	double ldexp(double x, int exp);
	float ldexpf(float x, int exp);
	long double ldexpl(long double x, int exp);

7.12.6.7 The log functions
Synopsis
	#include <math.h>
	double log(double x);
	float logf(float x);
	long double logl(long double x);

7.12.6.8 The log10 functions
Synopsis
	#include <math.h>
	double log10(double x);
	float log10f(float x);
	long double log10l(long double x);

7.12.6.9 The log1p functions
Synopsis
	#include <math.h>
	double log1p(double x);
	float log1pf(float x);
	long double log1pl(long double x);

7.12.6.10 The log2 functions
Synopsis
	#include <math.h>
	double log2(double x);
	float log2f(float x);
	long double log2l(long double x);

7.12.6.11 The logb functions
Synopsis
	#include <math.h>
	double logb(double x);
	float logbf(float x);
	long double logbl(long double x);

7.12.6.12 The modf functions
Synopsis
	#include <math.h>
	double modf(double value, double *iptr);
	float modff(float value, float *iptr);
	long double modfl(long double value, long double *iptr);

7.12.6.13 The scalbn and scalbln functions
Synopsis
	#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 int n);
	float scalblnf(float x, long int n);
	long double scalblnl(long double x, long int n);

7.12.7		Power and absolute-value functions

7.12.7.1 The cbrt functions
Synopsis
	#include <math.h>
	double cbrt(double x);
	float cbrtf(float x);
	long double cbrtl(long double x);

7.12.7.2 The fabs functions
Synopsis
	#include <math.h>
	double fabs(double x);
	float fabsf(float x);
	long double fabsl(long double x);

7.12.7.3 The hypot functions
Synopsis
	#include <math.h>
	double hypot(double x, double y);
	float hypotf(float x, float y);
	long double hypotl(long double x, long double y);

7.12.7.4 The pow functions
Synopsis
	#include <math.h>
	double pow(double x, double y);
	float powf(float x, float y);
	long double powl(long double x, long double y);

7.12.7.5 The sqrt functions
Synopsis
	#include <math.h>
	double sqrt(double x);
	float sqrtf(float x);
	long double sqrtl(long double x);

7.12.8		Error and gamma functions

7.12.8.1 The erf functions
Synopsis
	#include <math.h>
	double erf(double x);
	float erff(float x);
	long double erfl(long double x);

7.12.8.2 The erfc functions
Synopsis
	#include <math.h>
	double erfc(double x);
	float erfcf(float x);
	long double erfcl(long double x);

7.12.8.3 The lgamma functions
Synopsis
	#include <math.h>
	double lgamma(double x);
	float lgammaf(float x);
	long double lgammal(long double x);

7.12.8.4 The tgamma functions
Synopsis
	#include <math.h>
	double tgamma(double x);
	float tgammaf(float x);
	long double tgammal(long double x);

7.12.9		Nearest integer functions

7.12.9.1 The ceil functions
Synopsis
	#include <math.h>
	double ceil(double x);
	float ceilf(float x);
	long double ceill(long double x);

7.12.9.2 The floor functions
Synopsis
	#include <math.h>
	double floor(double x);
	float floorf(float x);
	long double floorl(long double x);

7.12.9.3 The nearbyint functions
Synopsis
	#include <math.h>
	double nearbyint(double x);
	float nearbyintf(float x);
	long double nearbyintl(long double x);

7.12.9.4 The rint functions
Synopsis
	#include <math.h>
	double rint(double x);
	float rintf(float x);
	long double rintl(long double x);

7.12.9.5 The lrint and llrint functions
Synopsis
	#include <math.h>
	long int lrint(double x);
	long int lrintf(float x);
	long int lrintl(long double x);
	long long int llrint(double x);
	long long int llrintf(float x);
	long long int llrintl(long double x);

7.12.9.6 The round functions
Synopsis
	#include <math.h>
	double round(double x);
	float roundf(float x);
	long double roundl(long double x);

7.12.9.7 The lround and llround functions
Synopsis
	#include <math.h>
	long int lround(double x);
	long int lroundf(float x);

7.12.9.8 The trunc functions
Synopsis
	#include <math.h>
	double trunc(double x);
	float truncf(float x);
	long double truncl(long double x);

7.12.10		Remainder functions

7.12.10.1 The fmod functions
Synopsis
	#include <math.h>
	double fmod(double x, double y);
	float fmodf(float x, float y);
	long double fmodl(long double x, long double y);

7.12.10.2 The remainder functions
Synopsis
	#include <math.h>
	double remainder(double x, double y);
	float remainderf(float x, float y);
	long double remainderl(long double x, long double y);

7.12.10.3 The remquo functions
Synopsis
	#include <math.h>
	double remquo(double x, double y, int *quo);
	float remquof(float x, float y, int *quo);
	long double remquol(long double x, long double y, int *quo);

7.12.11		Manipulation functions

7.12.11.1 The copysign functions
Synopsis
	#include <math.h>
	double copysign(double x, double y);
	float copysignf(float x, float y);
	long double copysignl(long double x, long double y);

7.12.11.2 The nan functions
Synopsis
	#include <math.h>
	double nan(const char *tagp);
	float nanf(const char *tagp);
	long double nanl(const char *tagp);

7.12.11.3 The nextafter functions
Synopsis
	#include <math.h>
	double nextafter(double x, double y);
	float nextafterf(float x, float y);
	long double nextafterl(long double x, long double y);

7.12.11.4 The nexttoward functions
Synopsis
	#include <math.h>
	double nexttoward(double x, long double y);
	float nexttowardf(float x, long double y);
	long double nexttowardl(long double x, long double y);

7.12.12		Maximum, minimum, and positive difference functions

7.12.12.1 The fdim functions
Synopsis
	#include <math.h>
	double fdim(double x, double y);
	float fdimf(float x, float y);
	long double fdiml(long double x, long double y);

7.12.12.2 The fmax functions
Synopsis
	#include <math.h>
	double fmax(double x, double y);
	float fmaxf(float x, float y);
	long double fmaxl(long double x, long double y);

7.12.12.3 The fmin functions
Synopsis
	#include <math.h>
	double fmin(double x, double y);
	float fminf(float x, float y);
	long double fminl(long double x, long double y);

7.12.13		Floating multiply-add

7.12.13.1 The fma functions
Synopsis
	#include <math.h>
	double fma(double x, double y, double z);
	float fmaf(float x, float y, float z);
	long double fmal(long double x, long double y, long double z);

7.12.14		Comparison macros

7.12.14.1 The isgreater macro
Synopsis
	#include <math.h>
	int isgreater(real-floating x, real-floating y);

7.12.14.2 The isgreaterequal macro
Synopsis
	#include <math.h>
	int isgreaterequal(real-floating x, real-floating y);

7.12.14.3 The isless macro
Synopsis
	#include <math.h>
	int isless(real-floating x, real-floating y);

7.12.14.4 The islessequal macro
Synopsis
	#include <math.h>
	int islessequal(real-floating x, real-floating y);

7.12.14.5 The islessgreater macro
Synopsis
	#include <math.h>
	int islessgreater(real-floating x, real-floating y);

7.12.14.6 The isunordered macro
Synopsis
	#include <math.h>
	int isunordered(real-floating x, real-floating y);



More information about the Newlib mailing list