|
Reference · Data types Standard C · assert.h · complex.h · ctype.h · fenv.h · float.h · locale.h · math.h · setjmp.h · signal.h · stdarg.h · stddef.h · stdio.h · stdlib.h · string.h · time.h Standard C++ · IOstream · new Win32 · gc.h DOS, DOS32, Win16 · bios.h · cerror.h · disp.h · dos.h · dos.h part 2 · emm.h · handle.h · int.h · msmouse.h · sound.h · swap.h · tsr.h · winio.h Other C · bitops.h · conio.h · controlc.h · direct.h · fltpnt.h · io.h · page.h · process.h · search.h · sys\stat.h · tabsize.h · trace.h · utime.h · unmangle.h · util.h Other C++ · regexp.h · class complex |
math.h
fpclassifyHeader#include <math.h> int fpclassify(x); DescriptionThis function, implemented as a macro, determines if a floating point value belongs to a special class. x's type is either float, double or long double. The following values can be compared to the result from fpclassify. They classify floating point values and expand to a unique constant expression of type int:
Return Value Returns a constant that reflects the class of the floating-point expression x. Compatibility DOS Windows 3.x Phar Lap DOSX Win32 isfinite, isinf, isnan, isnormalHeader#include <math.h> int isfinite(x); int isinf(x); int isnan(x); int isnormal(x); DescriptionEach of these takes an argument of type float, double, or long double; and determines if the argument's value is of the classified type.
Return ValueReturns non-zero if a match, 0 if not.
CompatibilityC99 7.12.3
See AlsofpclassifysignbitHeader#include <math.h> int signbit(x); DescriptionExamines the sign bit of the floating-point value x (including NaNs, infinities, and zero). signbit is implemented as a macro, and x can be a float, double or long double.Return Value Non-zero if the sign bit is 1; zero if the sign bit is 0. Compatibility C99 7.12.3.6
acosHeadermath.hfltenv.h (Required for exception values) Prototypedouble acos(double x);float acosf(float x); long double acosl(long double x); DescriptionThe acos functions calculate the principal value of the arc cosine of x.Return Value The arc cosine of x. Special Results
CompatibilityDOS Windows 3.x Phar Lap DOSX Win32See Also asin, atan, atan2, cos, cosh, hypot, sin, sinh, tan, tanh Example
/* Example of acos */
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
void main()
{
double d;
double result;
printf("Enter a double:");
scanf("%lg", &d);
result = acos(d);
printf("\nacos(%lg) = %lg\n", d, result);
}
Output
Enter a double:. 45 asinHeadermath.herrno.h fltenv.h (Required for exception values) Prototype
double asin(double x); DescriptionThe asin functions calculate the principal value of the arcsine of x. asin calculates the arcsine of a double value; asinf calculates the arcsine of a floating-point value; and asinl calculates the arcsine of a long double value. The value of x must be between -1 and 1.Return Value The arcsine of x. Each function returns a value ranging from -π/2 to π/2. For asinl, if the x argument is outside the range of -1 to 1, the function returns NAN (not a number) and errno is set to EDOM, for domain error.
Special Results
value of x return value invalid? ±0.0 ±0.0 no >1.0 NAN yes <-1.0 NAN yesCompatibility DOS Windows 3.x Phar Lap DOSX Win32 See Also
acos Example
/* Example of asin */
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
void main()
{
double d;
printf("Enter a double : ");
scanf("%lg", &d);
printf("\nasin(%g) = %g\n", d, asin(d));
}
Output
Enter a double :. 45 atanHeadermath.hfltenv.h (Required for exception values) Prototype
double atan(double x); DescriptionThe atan functions calculate the arc tangent of x.Return Value The arc tangent of x. This is a value in the range of -π/2 to π/2.
Special Results
value of x return value invalid? ±0.0 ±0.0 no ±INFINITY NAN yesCompatibility DOS Windows 3.x Phar Lap DOSX Win32 See Also
acos Example
/* Example of atan */
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
void main()
{
double d;
printf("Enter a double : ");
scanf("%lg", &d);
printf("\natan(%g) = %g\n", d, atan(d));
}
Output
Enter a double :. 45 atan2Headermath.hfltenv.h (Required for exception values) Prototype
double atan2(double y, double x); DescriptionThe atan2 functions calculate the arc tangent of y/x.Return Value The arc tangent of y/x. This is a value in the range -π to π. If one argument is a NaN, that NaN is returned; if both arguments are NaNs, either one may be returned. If both arguments are 0, these functions set errno to EDOM, print a _DOMAIN error message to stderr, and return 0. Special Results
value of y value of x return value ±0.0 > 0.0 ±0.0 ±0.0 ±0.0 ±0.0 ±0.0 < 0.0 ±π ±0.0 -0.0 ±π > 0.0 ±0.0 π/2 < 0.0 ±0.0 π/2 > 0.0 INFINITY ±0.0 ±INFINITY anything ±π/2 > 0.0 -INFINITY ±π ±INFINITY INFINITY ±π/4 ±INFINITY -INFINITY ±3π/4Compatibility DOS Windows 3.x Phar Lap DOSX Win32 See Also
acos Example
/* Example of atan2 */
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
void main()
{
double d1, d2;
printf("Enter two doubles : ");
scanf("%lg %lg", &d1, &d2);
printf("\natan2(%g, %g) = %g\n", d1, d2, atan2(d1,d2));
}
Output
Enter two doubles :. 3 .4 cbrtHeadermath.hfltenv.h (required for exception values) Prototypedouble cbrt(double x);float cbrtf(float x); long double cbrtl(long double x); DescriptionThe cbrt functions calculate the cube root of x.Return ValueThe cube root of x.Special Results
CompatibilityC99 DOS Windows 3.x Phar Lap DOSX Win32See Alsoexpexpml pow sqrt ceilHeadermath.hPrototype
double ceil(double x); DescriptionReturns the value of x rounded upward to the next integer (toward positive infinity.)Return Value x rounded up to the next integer. Compatibility DOS Windows 3.x Phar Lap DOSX Win32 See Also
floor Example
/* Example for ceil */
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
void main()
{
double d;
printf("Enter a double: ");
scanf("%lg",& d);
printf("\nCeil (%lg) = %lg\n", d, ceil(d));
}
Output
Enter a double: 3.34 cosHeadermath.hfltenv.h (required for exception values) Prototype
double cos(double x); DescriptionThe cos functions calculate the cosine of x (measured in radians).Return Value The cosine of x. If an error occurs because x is too large, errno is set to ERANGE. Special Results value of x return value invalid? ±INFINITY NAN yesCompatibility DOS Windows 3.x Phar Lap DOSX Win32 See Also
cosh
expHeadermath.hPrototypedouble exp(double x);float expf(float x); long double expl(long double x); DescriptionThe exp functions calculate the value of the natural logarithm base (e) raised to the power of x.Return ValueThe value of ex. Otherwise, on overflow, returns HUGE_VAL and sets errno to ERANGE. On underflow, returns 0.Special Results
CompatibilityC99 DOS Windows 3.x Phar Lap DOSX Win32See Alsoexp2expm1 log log1p log10 pow sqrt Example
/* Example of exp */
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
int main()
{
double d;
double result;
printf("Enter a double:");
scanf("%lg", &d);
result = exp(d);
printf("\nexp(%lg) = %lg\n", d, result);
return 0;
}
OutputEnter a double: 2.34exp(2.34) = 10.3812 exp2Headermath.hPrototypedouble exp2(double x);float exp2f(float x); long double exp2l(long double x); DescriptionThe exp2 functions calculate the value of 2 raised to the power of x.Return ValueThe value of 2x. Otherwise, on overflow, returns HUGE_VAL and sets errno to ERANGE. On underflow, returns 0.Special Results
CompatibilityC99 DOS Windows 3.x Phar Lap DOSX Win32See Alsoexpexpm1 log log1p log10 pow sqrt expm1Headermath.hPrototype
double expm1(double x); DescriptionCalculates the value of the natural logarithm base (e) raised to the power of x, minus 1. For very small x, expm1(x) is more accurate than exp(x) -1.Return Value The value of ex-1 Special Results
Compatibility DOS Windows 3.x Phar Lap DOSX Win32 See Also
fabsHeadermath.hPrototype
double fabs(double x); DescriptionThe fabs, fabsf, and fabsl functions calculate the absolute value of floating-point number x.Return Value The absolute value of x.
Special Results
Compatibility DOS Windows 3.x Phar Lap DOSX Win32 See Also Example
/* Example of fabs */
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
void main()
{
double d;
double result;
printf("Enter a double:");
scanf("%lg", &d);
result = fabs(d);
printf("\nfabs(%lg) = %lg\n", d, result);
}
Output
Enter a double:-2.34 floorHeadermath.hPrototype
double floor(double x); DescriptionReturns the value of x rounded down to the nearest integer.Return Value A floating-point value that represents x rounded down to the nearest integer. Compatibility DOS Windows 3.x Phar Lap DOSX Win32 See Also
ceil Example
/* Example of floor
Also demonstrates floorl, floorf
*/
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
void main()
{
double d;
printf("Enter a double: ");
scanf("%lg", &d);
printf("\nfloor(%g)=%g\n", d, floor (d));
}
Output
Enter a double: 3.14 floor(3.14)= 3 fmodHeadermath.hfltenv.h (Required for exception values) Prototype
double fmod(double x, double y); DescriptionThese functions calculate the floating-point remainder of x/y.Return Value The value of x -i * y, where i is the number of times that y can be completely subtracted from x. The result has the same sign as x. Special Results value of x value of y return value invalid? ±0.0 not 0.0 ±0.0 no ±INFINITY anything NAN yes anything ±0.0 NAN yes !=±INFINITY ±INFINITY x no Compatibility DOS Windows 3.x Phar Lap DOSX Win32 See Also Example
/* Example for fmod
Also demonstrates fmodf, fmodl
*/
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
void main()
{
double d1, d2, r;
printf("Enter two doubles: ");
scanf("%lg %lg", &d1, &d2);
r = fmod(d1, d2);
printf("fmod(%g, %g)=%g\n", d1, d2, r);
}
Output
Enter two doubles: 16 7 frexpHeadermath.h Prototype
double frexp(double x, int *exp); DescriptionThe frexp, frexpf, _frexpl, and frexpl functions break a floating-point number (x) into a mantisa (m) and an exponent (n), such that 0.5 <= |m| < 1.0 and x = m * 2n. The integer exponent n is stored at the location pointed to by exp.Return Value These functions return the mantissa. If x is 0, the functions return 0 for both the mantissa and the exponent. There is no error return.
Special Results value of x return value *exp after? Compatibility DOS Windows 3.x Phar Lap DOSX Win32 See Also Example
/* Example for frexp */
#include <stdio.h>
#include <stdio.h>
#include <math.h>
void main()
{
int e;
double d, r;
printf("Enter a double: ");
scanf("%lg", &d);
r = frexp (d, &e);
printf("%g, = %g * 2^%d.\n", d, r, e);
}
Output
Enter a double: 102 ilogb
CompatibilityC99 7.12.6.5, Win32See Alsologbloglp logpf log10 log ldexpHeadermath.hPrototype
double ldexp(double n, int exp); DescriptionEach function uses the following form to multiply a number by an integral power of two:n * 2exp Return Value The value of n * 2exp. Compatibility DOS Windows 3.x Phar Lap DOSX Win32 See Also Example
/* Example for ldexp */
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
void main()
{
int e;
double d, r;
printf("Enter a double and an int: ");
scanf("%lg %d", &d, &e);
r = ldexp (d, e);
printf("%g = %g * 2^%d.\n\n", r, d, e);
}
Output
Enter a double and an int: 125 5 logHeadermath.hfltenv.h (Required for exception values) Prototypedouble log(double x);float logf(float x); long double logl(long double x); DescriptionThe log functions calculate the natural logarithm of x.Return ValueThe natural logarithm of x. If x < 0, a domain error is returned. If x == 0, a range error is returned.Special Results
CompatibilityDOS Windows 3.x Phar Lap DOSX Win32See Alsologlplogpf log10 Example
/* Example for log
Also demonstrates logl
*/
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
void main()
{
double d;
printf("Enter a double: ");
scanf("%lg", &d);
printf("\nlog(%g)=%g\n\n", d, log(d));
}
OutputEnter a double: 234log(234)= 5.45532 log2Headermath.hPrototypedouble log2(double x);float log2f(float x); long double log2l(long double x); DescriptionThe log2 functions calculate the base-2 logarithm of x, log2x.Return ValueThe natural logarithm of x. If x < 0, a domain error is returned. If x == 0, a range error is returned.Special Results
CompatibilityC99 Win32See Alsologlplogpf log10 log logb
CompatibilityC99 Win32See Alsoilogbloglp logpf log10 log log10Headermath.hfltenv.h (Required for exception values) Prototype
double log10(double x); DescriptionThe log10 functions calculate the base-10 logarithm of x.Return Value The base-10 logarithm of x. If x < 0, a domain error is returned. If x == 0, a range error is returned. Special Results
Compatibility DOS Windows 3.x Phar Lap DOSX Win32 See Also Example
/* Example for log10 */
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
int main()
{
double d;
printf("Enter a double: ");
scanf("%lg", &d);
printf("\nlog10(%g)=%g\n\n", d, log10(d));
return 0;
}
Output
Enter a double: 234 log10(234)= 2.36922 log1p, log1pfHeadermath.hfltenv.h (Required for exception values) Prototype
double log1p(double x); DescriptionThe log1p and log1pf functions calculate the natural logarithm of 1 + x. For very small x, log1p(x) will be more accurate than log(1 + x).Return Value The natural logarithm of 1 + x. Special Results
CompatibilityDOS Windows 3.x Phar Lap DOSX Win32See Also Example
/* Example for log1p
Also demonstrates loglpf
*/
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
void main()
{
double d;
printf("Enter a double: ");
scanf("%lg", &d);
printf("\nlog1p(%g)=%g\n\n", d, log1p(d));
}
Output
Enter a double: 1.234 log1p(1.234)= 0.803794 matherr, _matherrlHeadermath.hPrototype
int matherr(struct exception *except); DescriptionThe matherr and _matherrl functions process errors that have been generated by math functions. The math functions call a math error function whenever an error occurs. Users can also provide their own math error functions to implement special error handling. The _matherrl is called for errors in long double math.A pointer to the exception structure will be passed to a user-supplied math error function when an error occurs. The exception structures, _exception and _exceptionl are defined in math.h. They have the following elements:
Return Value These functions return 0 to indicate an error, non-zero for success. Compatibility DOS Windows 3.x Phar Lap DOSX Win32 See Also The other math functions
modfHeadermath.hPrototype
double modf(double x, double *iptr); DescriptionThe modf functions break x into its integral and fraction parts. each of which has the same sign as x. The integral portion is stored in the double pointed to by iptr.Return Value The signed fractional portion of x. Special Results value of x return value *iptr after ±INFINITY ±0.0 ±INFINITY Compatibility DOS Windows 3.x Phar Lap DOSX Win32 Example
/* Example for modf
Also demonstrates modfl
*/
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
void main()
{
double d, frac, intr;
printf("Enter a double: ");
scanf("%lg", &d);
frac = modf (d, &intr);
printf("\nFor %g, the fractional part is
%g,\nand the integral part is "
"%g.\n", d, frac, intr);
}
Output
Enter a double: 123.456
For 123.456, the fractional part is 0.456, nextafterHeaderfltpnt.hPrototype
double nextafter(double x, double y); DescriptionCalculates the next representable value after x in the direction of y.Return Value If y is greater than x, the result will be the next largest floating-point value; if y is less than x, the result will be the next smallest value. If x and y are equal, the result is x. The FE_INEXACT and FE_OVERFLOW exceptions will be raised if x is finite and the function result is infinite. The FE_INEXACT and FE_UNDERFLOW exceptions will be raised if the function value is subnormal, and x is not equal to y. Compatibility DOS Windows 3.x Phar Lap DOSX Win32 Example
/* Example for nextafter
Also demonstrates nextafterf
*/
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <fltpnt.h>
void main()
{
double d1, d2, r;
printf("Enter two doubles: ");
scanf("%lg %lg", &d1, &d2);
r = nextafter(d1, d2);
printf("nextafter(%g, %g)=%. 16f\n", d1,
d2, r);
}
Output
Enter two doubles: 1 2 poly, polylHeadermath.hPrototype
double poly(double x, int deg, double coeff[]); Descriptionpoly and polyl evaluate a polynomial of the form:(coeff[deg] * x + coeff [deg-1]) * x +...+ coeff[0]. Argument x is the base value; deg is the maximum degree, and coeff is an array containing the coefficients of the values. The polyl function is the long double version of poly. Return Value Both functions return the calculated value of the polynomial. Compatibility DOS Windows 3.x Phar Lap DOSX Win32 Example
/* Example for poly
Also demonstrates polyl
*/
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
void main()
{
double coeff[4], x = 1.2, y;
coeff[0] = 0.0;
coeff[1] = 1.0;
coeff[2] = 2.0;
coeff[3] = 3.0;
y = poly(x, 3, coeff);
printf("poly(%g, 3, {%g, %g, %g, %g}) =
%g\n", x, coeff[0], coeff[1],
coeff[2], coeff[3], y);
}
Output
poly(1.2, 3, {0, 1, 2, 3}) = 9.264 powHeadermath.hPrototype
double pow(double x, double y); DescriptionThe pow functions calculate xy.Return Value x raised to the power of y. If an overflow occurs, the pow functions set errno to ERANGE and return _HUGE_VAL or _LHUGE_VAL (if the return type is long double). Special Results
value of x value of y return value div 0 inv anything ±0.0 1.0 no no |x| > 1 +INFINITY +INFINITY no no |x| < 1 +INFINITY +0.0 no no |x| > 1 -INFINITY +0.0 no no |x| < 1 -INFINITY +INFINITY no no +INFINITY y > 0.0 +INFINITY no no +INFINITY y < 0.0 +0.0 no no -INFINITY odd integer>0.0 -INFINITY no no -INFINITY >0.0,not odd +INFINITY no no integer -INFINITY odd integer<0.0 -0.0 no no -INFINITY <0.0, not odd +0.0 no no integer ±1.0 ±INFINITY NAN no yes <0.0 finite, NAN no yes nonintegral ±0.0 odd integer <0.0±INFINITY yes no ±0.0 <0.0, not odd +INFINITY yes no integer ±0.0 odd integer>0.0 ±0.0 no no ±0.0 >0.0, not odd +0.0 no no integer Compatibility DOS Windows 3.x Phar Lap DOSX Win32 See Also Example
/* Example for pow
Also demonstrates powl
*/
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
void main()
{
double d1, d2;
printf("Enter two doubles: ");
scanf("%lg %lg", &d1, &d2);
printf("\npow(%g, %g)=%g\n", d1, d2,
pow (d1, d2));
}
Output
Enter two doubles: 2 16 pow(2, 16)= 65536 sinHeadermath.hfltenv.h (required for exception values) Prototypedouble sin(double x);float sinf(float x); long double sinl(long double x); DescriptionThe sin functions calculate the sine of x (measured in radians).Return ValueThe sine of x. If an error occurs because x is too large, errno is set to ERANGE.Special Resultsvalue of x return value invalid? ±0.0 ±0.0 no ±INFINITY NAN yes CompatibilityDOS Windows 3.x Phar Lap DOSX Win32See Alsoacosasin cos sinh Example
/* Example of sin()
*/
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
void main()
{
double d;
printf("Enter a double: ");
scanf("%lg", &d);
printf("\nsin(%g)=%g\n", d, sin(d));
}
OutputEnter a double: 100 sin(100)=-0.506366 sinhHeadermath.hfltenv.h Prototype
double sinh(double x); DescriptionThe sinh functions calculate the hyperbolic sine of x.Return Value The hyperbolic sine of x. If the value of x is too large, errno is set to ERANGE. Special Results
Compatibility DOS Windows 3.x Phar Lap DOSX Win32 See Also Example
/* Example of sinh
Also demonstrates sinh
*/
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
void main()
{
double d;
printf("Enter a double: ");
scanf("%lg", &d);
printf("\nsinh(%g)=%g\n", d, sinh (d));
}
Output
Enter a double: 12 sinh(12)= 81377.4 sqrtHeadermath.hfltenv.h (required for exception values) Prototypedouble sqrt(double x);float sqrtf(float x); long double sqrtl(long double x); DescriptionThe sqrt functions calculate the square root of x.Return ValueThe square root of x.Special Results
CompatibilityC99 DOS Windows 3.x Phar Lap DOSX Win32See Alsoexpexpml pow cbrt Example
/* Example of sqrt */
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
int main()
{
double d;
printf("Enter a double: ");
scanf("%lg", &d);
printf("\nsqrt(%g)=%g\n", d, sqrt(d));
return 0;
}
OutputEnter a double: 81sqrt(81)= 9 tanHeadermath.h fltenv.h (required for exception values)Prototype
double tan(double x); DescriptionThe tan functions calculate the tangent of x (measured in radians).Return Value The tangent of x. If x is too large, a partial loss of significance may occur. In this case, the tan functions set global variable errno to ERANGE and generate a _PLOSS error. If x is so large that significance is totally lost, tan functions print a _TLOSS error message to stderr, set errno to ERANGE, and return 0. Special Results value of x return value invalid? ±0.0 ±0.0 no ±INFINITY NAN yesCompatibility DOS Windows 3.x Phar Lap DOSX Win32 See Also Example
/* Example of tan
Also demonstrates tanl
*/
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
void main()
{
double d;
printf("Enter a double: ");
scanf("%lg", &d);
printf("\ntan(%g)=%g\n", d, tan (d));
}
Output
Enter a double: 100 tan(100)=-0.587214 tanhHeaderPrototype
double tanh(double x); DescriptionThe tanh functions calculate the hyperbolic tangent of x.Return Value The hyperbolic tangent of x.
Special Results
value of x return value invalid? ±0.0 ±0.0 no ±INFINITY ±1.0 no Compatibility DOS Windows 3.x Phar Lap DOSX Win32 See Also Example
/* Example of tanh */
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
void main()
{
double d;
printf("Enter a double: ");
scanf("%lg", &d);
printf("\ntanh(%g)=%g\n", d, tanh(d));
}
OutputEnter a double: 3 tanh(3)= 0.995055 _cabs, _cabslHeadermath.hPrototype
double _cabs(struct _complex z); DescriptionThe _cabs and _cabsl functions calculate the absolute value of the complex number stored in the z structure. This structure is composed of a real component x and an imaginary component y. In the _cabs function, x and y are double values; in the _cabsl function, x and y are long double values.Synonym
Function: cabs, cabl Return Value The absolute value of z. If an overflow occurs, these functions return HUGE_VAL, and set variable errno to ERANGE. Compatibility DOS Windows 3.x Phar Lap DOSX Win32 See Also Example
/* Example for cabs */
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
void main()
{
struct _complex z;
double retval;
z. x = 3.0;
z. y = 1.0;
retval = _cabs(z);
printf("cabs of (%g,%gi) = %g", z. x, z. y,
retval);
}
Output
cabs of (3,1i) = 3.16228 hypotHeadermath.hPrototype
float hypotf(float x, float y); DescriptionThe hypot functions calculate the length of the hypotenuse of a right-angled triangle with sides of length x and y. The hypotenuse is the value of the square root of the sums of the squares of x and y:sqrt(x2 + y2) Return ValueThe hypotenuse of a right-angled triangle with sides x and y.Special Results
Note that hypot(x,y), hypot(y,x) and hypot(x,-y) are equivalent. Compatibility ANSI C99, DOS, Windows 3.x, Phar Lap, DOSX, Win32 See Also
cosh Example
/* Example for hypot */
#include <stdio.h>
#include <math.h>
void main()
{
double d1, d2;
printf("Enter two doubles: ");
scanf("%Lg %Lg", &d1, &d2);
printf("\nhypot (%g, %g) = %g\n", d1, d2,
hypot (d1, d2));
}
Output
Enter two doubles: 5 5 |