LCOV - code coverage report
Current view: top level - src - e_atan2l.c (source / functions) Coverage Total Hit
Test: app.info Lines: 0.0 % 49 0
Test Date: 2024-01-11 15:52:50 Functions: 0.0 % 1 0
Branches: 0.0 % 54 0

             Branch data     Line data    Source code
       1                 :             : 
       2                 :             : /* @(#)e_atan2.c 1.3 95/01/18 */
       3                 :             : /* FreeBSD: head/lib/msun/src/e_atan2.c 176451 2008-02-22 02:30:36Z das */
       4                 :             : /*
       5                 :             :  * ====================================================
       6                 :             :  * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
       7                 :             :  *
       8                 :             :  * Developed at SunSoft, a Sun Microsystems, Inc. business.
       9                 :             :  * Permission to use, copy, modify, and distribute this
      10                 :             :  * software is freely granted, provided that this notice 
      11                 :             :  * is preserved.
      12                 :             :  * ====================================================
      13                 :             :  *
      14                 :             :  */
      15                 :             : 
      16                 :             : #include "cdefs-compat.h"
      17                 :             : //__FBSDID("$FreeBSD: src/lib/msun/src/e_atan2l.c,v 1.3 2008/08/02 19:17:00 das Exp $");
      18                 :             : 
      19                 :             : /*
      20                 :             :  * See comments in e_atan2.c.
      21                 :             :  * Converted to long double by David Schultz <das@FreeBSD.ORG>.
      22                 :             :  */
      23                 :             : 
      24                 :             : #include <float.h>
      25                 :             : #include <openlibm_math.h>
      26                 :             : 
      27                 :             : #include "invtrig.h"
      28                 :             : #include "math_private.h"
      29                 :             : 
      30                 :             : static volatile long double
      31                 :             : tiny  = 1.0e-300;
      32                 :             : static const long double
      33                 :             : zero  = 0.0;
      34                 :             : 
      35                 :             : #ifdef __i386__
      36                 :             : /* XXX Work around the fact that gcc truncates long double constants on i386 */
      37                 :             : static volatile double
      38                 :             : pi1 =  3.14159265358979311600e+00,      /*  0x1.921fb54442d18p+1  */
      39                 :             : pi2 =  1.22514845490862001043e-16;      /*  0x1.1a80000000000p-53 */
      40                 :             : #define pi      ((long double)pi1 + pi2)
      41                 :             : #else
      42                 :             : static const long double
      43                 :             : pi =  3.14159265358979323846264338327950280e+00L;
      44                 :             : #endif
      45                 :             : 
      46                 :             : OLM_DLLEXPORT long double
      47                 :           0 : atan2l(long double y, long double x)
      48                 :             : {
      49                 :             :         union IEEEl2bits ux, uy;
      50                 :             :         long double z;
      51                 :             :         int32_t k,m;
      52                 :             :         int16_t exptx, expsignx, expty, expsigny;
      53                 :             : 
      54                 :           0 :         uy.e = y;
      55                 :           0 :         expsigny = uy.xbits.expsign;
      56                 :           0 :         expty = expsigny & 0x7fff;
      57                 :           0 :         ux.e = x;
      58                 :           0 :         expsignx = ux.xbits.expsign;
      59                 :           0 :         exptx = expsignx & 0x7fff;
      60                 :             : 
      61         [ #  # ]:           0 :         if ((exptx==BIAS+LDBL_MAX_EXP &&
      62   [ #  #  #  # ]:           0 :              ((ux.bits.manh&~LDBL_NBIT)|ux.bits.manl)!=0) ||        /* x is NaN */
      63                 :           0 :             (expty==BIAS+LDBL_MAX_EXP &&
      64         [ #  # ]:           0 :              ((uy.bits.manh&~LDBL_NBIT)|uy.bits.manl)!=0))  /* y is NaN */
      65                 :           0 :             return x+y;
      66   [ #  #  #  # ]:           0 :         if (expsignx==BIAS && ((ux.bits.manh&~LDBL_NBIT)|ux.bits.manl)==0)
      67                 :           0 :             return atanl(y);                                    /* x=1.0 */
      68                 :           0 :         m = ((expsigny>>15)&1)|((expsignx>>14)&2);  /* 2*sign(x)+sign(y) */
      69                 :             : 
      70                 :             :     /* when y = 0 */
      71   [ #  #  #  # ]:           0 :         if(expty==0 && ((uy.bits.manh&~LDBL_NBIT)|uy.bits.manl)==0) {
      72   [ #  #  #  # ]:           0 :             switch(m) {
      73                 :           0 :                 case 0: 
      74                 :           0 :                 case 1: return y;       /* atan(+-0,+anything)=+-0 */
      75                 :           0 :                 case 2: return  pi+tiny;/* atan(+0,-anything) = pi */
      76                 :           0 :                 case 3: return -pi-tiny;/* atan(-0,-anything) =-pi */
      77                 :             :             }
      78                 :             :         }
      79                 :             :     /* when x = 0 */
      80   [ #  #  #  # ]:           0 :         if(exptx==0 && ((ux.bits.manh&~LDBL_NBIT)|ux.bits.manl)==0)
      81         [ #  # ]:           0 :             return (expsigny<0)?  -pio2_hi-tiny: pio2_hi+tiny;
      82                 :             : 
      83                 :             :     /* when x is INF */
      84         [ #  # ]:           0 :         if(exptx==BIAS+LDBL_MAX_EXP) {
      85         [ #  # ]:           0 :             if(expty==BIAS+LDBL_MAX_EXP) {
      86   [ #  #  #  #  :           0 :                 switch(m) {
                      # ]
      87                 :           0 :                     case 0: return  pio2_hi*0.5+tiny;/* atan(+INF,+INF) */
      88                 :           0 :                     case 1: return -pio2_hi*0.5-tiny;/* atan(-INF,+INF) */
      89                 :           0 :                     case 2: return  1.5*pio2_hi+tiny;/*atan(+INF,-INF)*/
      90                 :           0 :                     case 3: return -1.5*pio2_hi-tiny;/*atan(-INF,-INF)*/
      91                 :             :                 }
      92                 :             :             } else {
      93   [ #  #  #  #  :           0 :                 switch(m) {
                      # ]
      94                 :           0 :                     case 0: return  zero  ;     /* atan(+...,+INF) */
      95                 :           0 :                     case 1: return -zero  ;     /* atan(-...,+INF) */
      96                 :           0 :                     case 2: return  pi+tiny  ;  /* atan(+...,-INF) */
      97                 :           0 :                     case 3: return -pi-tiny  ;  /* atan(-...,-INF) */
      98                 :             :                 }
      99                 :             :             }
     100                 :             :         }
     101                 :             :     /* when y is INF */
     102         [ #  # ]:           0 :         if(expty==BIAS+LDBL_MAX_EXP)
     103         [ #  # ]:           0 :             return (expsigny<0)? -pio2_hi-tiny: pio2_hi+tiny;
     104                 :             : 
     105                 :             :     /* compute y/x */
     106                 :           0 :         k = expty-exptx;
     107         [ #  # ]:           0 :         if(k > LDBL_MANT_DIG+2) {                    /* |y/x| huge */
     108                 :           0 :             z=pio2_hi+pio2_lo;
     109                 :           0 :             m&=1;
     110                 :             :         }
     111   [ #  #  #  # ]:           0 :         else if(expsignx<0&&k<-LDBL_MANT_DIG-2) z=0.0;    /* |y/x| tiny, x<0 */
     112                 :           0 :         else z=atanl(fabsl(y/x));               /* safe to do y/x */
     113   [ #  #  #  # ]:           0 :         switch (m) {
     114                 :           0 :             case 0: return       z  ;   /* atan(+,+) */
     115                 :           0 :             case 1: return      -z  ;   /* atan(-,+) */
     116                 :           0 :             case 2: return  pi-(z-pi_lo);/* atan(+,-) */
     117                 :           0 :             default: /* case 3 */
     118                 :           0 :                     return  (z-pi_lo)-pi;/* atan(-,-) */
     119                 :             :         }
     120                 :             : }
        

Generated by: LCOV version 2.0-115.g950771e