/programs/develop/ktcc/trunk/libc.obj/source/math/acosh.c |
---|
1,8 → 1,7 |
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ |
#include <math.h> |
double |
acosh(double x) |
double acosh(double x) |
{ |
return log(x + sqrt(x*x - 1)); |
} |
} |
/programs/develop/ktcc/trunk/libc.obj/source/math/asinh.c |
---|
1,9 → 1,7 |
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ |
#include <math.h> |
double |
asinh(double x) |
double asinh(double x) |
{ |
return x>0 ? log(x + sqrt(x*x + 1)) : -log(sqrt(x*x+1)-x); |
} |
/programs/develop/ktcc/trunk/libc.obj/source/math/atan2.s |
---|
30,7 → 30,7 |
fpatan |
ret |
isanan: |
movl $1, _errno |
movl $1, __errno |
fstp %st(0) |
fstp %st(0) |
fldl nan |
/programs/develop/ktcc/trunk/libc.obj/source/math/atanh.c |
---|
1,8 → 1,7 |
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ |
#include <math.h> |
double |
atanh(double x) |
double atanh(double x) |
{ |
return log((1+x)/(1-x)) / 2.0; |
} |
/programs/develop/ktcc/trunk/libc.obj/source/math/frexp.c |
---|
1,8 → 1,7 |
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ |
#include <math.h> |
double |
frexp(double x, int *exptr) |
double frexp(double x, int* exptr) |
{ |
union { |
double d; |
/programs/develop/ktcc/trunk/libc.obj/source/math/hypot.c |
---|
17,8 → 17,8 |
*/ |
/// #include <float.h> |
#include <errno.h> |
#include <math.h> |
#include <errno.h> |
/* Approximate square roots of DBL_MAX and DBL_MIN. Numbers |
between these two shouldn't neither overflow nor underflow |
26,15 → 26,13 |
#define __SQRT_DBL_MAX 1.3e+154 |
#define __SQRT_DBL_MIN 2.3e-162 |
double |
hypot(double x, double y) |
double hypot(double x, double y) |
{ |
double abig = fabs(x), asmall = fabs(y); |
double ratio; |
/* Make abig = max(|x|, |y|), asmall = min(|x|, |y|). */ |
if (abig < asmall) |
{ |
if (abig < asmall) { |
double temp = abig; |
abig = asmall; |
53,8 → 51,7 |
if ((ratio = asmall / abig) > __SQRT_DBL_MIN && abig < __SQRT_DBL_MAX) |
return abig * sqrt(1.0 + ratio*ratio); |
else |
{ |
else { |
/* Slower but safer algorithm due to Moler and Morrison. Never |
produces any intermediate result greater than roughly the |
larger of X and Y. Should converge to machine-precision |
80,8 → 77,7 |
#include <stdio.h> |
int |
main(void) |
int main(void) |
{ |
printf("hypot(3, 4) =\t\t\t %25.17e\n", hypot(3., 4.)); |
printf("hypot(3*10^150, 4*10^150) =\t %25.17g\n", hypot(3.e+150, 4.e+150)); |
/programs/develop/ktcc/trunk/libc.obj/source/math/ldexp.c |
---|
2,27 → 2,24 |
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ |
#include <math.h> |
double |
ldexp(double v, int e) |
double ldexp(double v, int e) |
{ |
double two = 2.0; |
if (e < 0) { |
e = -e; /* This just might overflow on two-complement machines. */ |
if (e < 0) |
{ |
e = -e; /* This just might overflow on two-complement machines. */ |
if (e < 0) return 0.0; |
while (e > 0) |
{ |
if (e & 1) v /= two; |
return 0.0; |
while (e > 0) { |
if (e & 1) |
v /= two; |
two *= two; |
e >>= 1; |
} |
} |
else if (e > 0) |
{ |
while (e > 0) |
{ |
if (e & 1) v *= two; |
} else if (e > 0) { |
while (e > 0) { |
if (e & 1) |
v *= two; |
two *= two; |
e >>= 1; |
} |
29,4 → 26,3 |
} |
return v; |
} |
/programs/develop/ktcc/trunk/libc.obj/source/math/sinh.c |
---|
3,13 → 3,10 |
double sinh(double x) |
{ |
if(x >= 0.0) |
{ |
if (x >= 0.0) { |
const double epos = exp(x); |
return (epos - 1.0/epos) / 2.0; |
} |
else |
{ |
} else { |
const double eneg = exp(-x); |
return (1.0/eneg - eneg) / 2.0; |
} |
/programs/develop/ktcc/trunk/libc.obj/source/math/tanh.c |
---|
7,11 → 7,9 |
return 1; |
else if (x < -50) |
return -1; |
else |
{ |
else { |
const double ebig = exp(x); |
const double esmall = 1.0/ebig; |
return (ebig - esmall) / (ebig + esmall); |
} |
} |