Add fabsf function

This commit is contained in:
Erik van der Kouwe 2010-01-08 07:27:11 +00:00
parent d1fd04e72a
commit 17b10f1bf3
3 changed files with 26 additions and 0 deletions

View file

@ -24,6 +24,7 @@ _PROTOTYPE( double cos, (double _x) );
_PROTOTYPE( double cosh, (double _x) ); _PROTOTYPE( double cosh, (double _x) );
_PROTOTYPE( double exp, (double _x) ); _PROTOTYPE( double exp, (double _x) );
_PROTOTYPE( double fabs, (double _x) ); _PROTOTYPE( double fabs, (double _x) );
_PROTOTYPE( double fabsf, (float _x) );
_PROTOTYPE( double floor, (double _x) ); _PROTOTYPE( double floor, (double _x) );
_PROTOTYPE( double fmod, (double _x, double _y) ); _PROTOTYPE( double fmod, (double _x, double _y) );
_PROTOTYPE( double frexp, (double _x, int *_exp) ); _PROTOTYPE( double frexp, (double _x, int *_exp) );

View file

@ -6,8 +6,15 @@
*/ */
/* $Header$ */ /* $Header$ */
float
fabsf(float x)
{
return x < 0 ? -x : x;
}
double double
fabs(double x) fabs(double x)
{ {
return x < 0 ? -x : x; return x < 0 ? -x : x;
} }

18
man/man3/fabs.3 Normal file
View file

@ -0,0 +1,18 @@
.TH FABS 3 "January 7, 2009"
.UC 4
.SH NAME
fabs, fabsf \- compute absolute value
.SH SYNOPSIS
.nf
.ft B
#include <math.h>
double fabs(double \fIx\fP);
float fabsf(float \fIx\fP);
.fi
.SH DESCRIPTION
\fBfabs\fP and \fBfabsf\fP return the absolute value of their argument.
.SH "RETURN VALUE
The return value is a number with the same magnitude as the argument and with
a positive sign.