1
0
mirror of https://github.com/adtools/clib2.git synced 2025-12-08 14:59:05 +00:00

- Implemented fmin()/fminf(), fmax()/fmaxf(), fdim()/fdimf() (C99).

git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@14962 87f5fb63-7c3d-0410-a384-fd976d0f7a62
This commit is contained in:
Olaf Barthel
2005-05-29 12:41:04 +00:00
parent 505c23237a
commit 49e98713d4
8 changed files with 133 additions and 24 deletions

View File

@ -61,6 +61,8 @@
tanhf(), tgamma(), tgammaf(), trunc() and truncf(), to be filled in tanhf(), tgamma(), tgammaf(), trunc() and truncf(), to be filled in
later... later...
- Implemented fmin()/fminf(), fmax()/fmaxf(), fdim()/fdimf() (C99).
c.lib 1.192 (12.5.2005) c.lib 1.192 (12.5.2005)

View File

@ -1,5 +1,5 @@
/* /*
* $Id: math.h,v 1.11 2005-05-29 10:09:55 obarthel Exp $ * $Id: math.h,v 1.12 2005-05-29 12:41:04 obarthel Exp $
* *
* :ts=4 * :ts=4
* *
@ -116,8 +116,8 @@ extern double hypot(double x,double y);
/* Note that the comparison operations performed on the floating point /* Note that the comparison operations performed on the floating point
data types ought to include float, double and long double. However, data types ought to include float, double and long double. However,
because the current (2005-06-12) compiler technology available on the because the current (2005-06-12) compiler technology available on the
Amiga does not support the long double type yet, this library is restricted Amiga does not support the long double type yet, this library is
to operations on float and double. */ restricted to operations on float and double. */
/****************************************************************************/ /****************************************************************************/
@ -134,8 +134,8 @@ extern float __nan;
/****************************************************************************/ /****************************************************************************/
#define INFINITY ((const float)__infinity) #define INFINITY ((const float)__infinity)
#define NAN ((const float)__nan) #define NAN ((const float)__nan)
/****************************************************************************/ /****************************************************************************/
@ -238,8 +238,23 @@ extern double nextafter(double x,double y);
/****************************************************************************/ /****************************************************************************/
extern double copysign(double x, double y);
extern float copysignf(float x, float y); extern float copysignf(float x, float y);
extern double copysign(double x, double y);
/****************************************************************************/
extern float fdimf(float x,float y);
extern double fdim(double x,double y);
/****************************************************************************/
extern float fminf(float x,float y);
extern double fmin(double x,double y);
/****************************************************************************/
extern float fmaxf(float x,float y);
extern double fmax(double x,double y);
/****************************************************************************/ /****************************************************************************/

View File

@ -1,5 +1,5 @@
/* /*
* $Id: math_fdim.c,v 1.1 2005-05-29 11:19:00 obarthel Exp $ * $Id: math_fdim.c,v 1.2 2005-05-29 12:41:03 obarthel Exp $
* *
* :ts=4 * :ts=4
* *
@ -44,8 +44,14 @@
double double
fdim(double x,double y) fdim(double x,double y)
{ {
/* ZZZ unimplemented */ double result;
return(0);
if(x > y)
result = x - y;
else
result = 0;
return(result);
} }
/****************************************************************************/ /****************************************************************************/

View File

@ -1,5 +1,5 @@
/* /*
* $Id: math_fdimf.c,v 1.1 2005-05-29 11:19:01 obarthel Exp $ * $Id: math_fdimf.c,v 1.2 2005-05-29 12:41:03 obarthel Exp $
* *
* :ts=4 * :ts=4
* *
@ -44,8 +44,14 @@
float float
fdimf(float x,float y) fdimf(float x,float y)
{ {
/* ZZZ unimplemented */ float result;
return(0);
if(x > y)
result = x - y;
else
result = 0;
return(result);
} }
/****************************************************************************/ /****************************************************************************/

View File

@ -1,5 +1,5 @@
/* /*
* $Id: math_fmax.c,v 1.1 2005-05-29 11:19:01 obarthel Exp $ * $Id: math_fmax.c,v 1.2 2005-05-29 12:41:03 obarthel Exp $
* *
* :ts=4 * :ts=4
* *
@ -44,8 +44,28 @@
double double
fmax(double x,double y) fmax(double x,double y)
{ {
/* ZZZ unimplemented */ double result;
return(0);
if(isnan(x))
{
if(isnan(y))
result = nan(NULL);
else
result = y;
}
else if (isnan(y))
{
result = x;
}
else
{
if(x > y)
result = x;
else
result = y;
}
return(result);
} }
/****************************************************************************/ /****************************************************************************/

View File

@ -1,5 +1,5 @@
/* /*
* $Id: math_fmaxf.c,v 1.1 2005-05-29 11:19:01 obarthel Exp $ * $Id: math_fmaxf.c,v 1.2 2005-05-29 12:41:03 obarthel Exp $
* *
* :ts=4 * :ts=4
* *
@ -44,8 +44,28 @@
float float
fmaxf(float x,float y) fmaxf(float x,float y)
{ {
/* ZZZ unimplemented */ float result;
return(0);
if(isnan(x))
{
if(isnan(y))
result = nanf(NULL);
else
result = y;
}
else if (isnan(y))
{
result = x;
}
else
{
if(x > y)
result = x;
else
result = y;
}
return(result);
} }
/****************************************************************************/ /****************************************************************************/

View File

@ -1,5 +1,5 @@
/* /*
* $Id: math_fmin.c,v 1.1 2005-05-29 11:19:01 obarthel Exp $ * $Id: math_fmin.c,v 1.2 2005-05-29 12:41:03 obarthel Exp $
* *
* :ts=4 * :ts=4
* *
@ -44,8 +44,28 @@
double double
fmin(double x,double y) fmin(double x,double y)
{ {
/* ZZZ unimplemented */ double result;
return(0);
if(isnan(x))
{
if(isnan(y))
result = nan(NULL);
else
result = y;
}
else if (isnan(y))
{
result = x;
}
else
{
if(x < y)
result = x;
else
result = y;
}
return(result);
} }
/****************************************************************************/ /****************************************************************************/

View File

@ -1,5 +1,5 @@
/* /*
* $Id: math_fminf.c,v 1.1 2005-05-29 11:19:01 obarthel Exp $ * $Id: math_fminf.c,v 1.2 2005-05-29 12:41:03 obarthel Exp $
* *
* :ts=4 * :ts=4
* *
@ -44,8 +44,28 @@
float float
fminf(float x,float y) fminf(float x,float y)
{ {
/* ZZZ unimplemented */ float result;
return(0);
if(isnan(x))
{
if(isnan(y))
result = nanf(NULL);
else
result = y;
}
else if (isnan(y))
{
result = x;
}
else
{
if(x < y)
result = x;
else
result = y;
}
return(result);
} }
/****************************************************************************/ /****************************************************************************/