home *** CD-ROM | disk | FTP | other *** search
/ Il CD di internet / CD.iso / SOURCE / D / LIBC / LIBC-4.6 / LIBC-4 / libc-linux / sysdeps / linux / i386 / math / atanh.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-03-18  |  1.0 KB  |  42 lines

  1. /* Copyright (C) 1993  Hongjiu Lu
  2. This file is part of the Linux C Library.
  3.  
  4. The Linux C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Library General Public License as
  6. published by the Free Software Foundation; either version 2 of the
  7. License, or (at your option) any later version.
  8.  
  9. The Linux C Library is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  12. Library General Public License for more details.  */
  13.  
  14. #include <ansidecl.h>
  15. #include <math.h>
  16. #include <errno.h>
  17.  
  18. double
  19. DEFUN(atanh, (x), double x)
  20. {
  21.   if (x <= -1.0 ) {
  22.     if (x == -1.0) {
  23.       return __infnan( -ERANGE);
  24.     }
  25.     return __infnan( EDOM);
  26.   } 
  27.  
  28.   if (x >= 1.0 ) {
  29.     if (x == 1.0) {
  30.       return __infnan( ERANGE);
  31.     }
  32.     return __infnan( EDOM);
  33.   } 
  34.  
  35.   x = (1.0 + x) / (1.0 - x);
  36.   __asm__ __volatile__ ("fldln2\n\t"
  37.               "fxch %%st(1)\n\t"
  38.               "fyl2x"
  39.             :"=t" (x) : "0" (x));
  40.   return x * 0.5;
  41. }
  42.