LCOV - code coverage report
Current view: top level - src - e_hypotf.c (source / functions) Coverage Total Hit
Test: app.info Lines: 65.2 % 46 30
Test Date: 2024-01-11 15:52:50 Functions: 100.0 % 1 1
Branches: 63.6 % 22 14

             Branch data     Line data    Source code
       1                 :             : /* e_hypotf.c -- float version of e_hypot.c.
       2                 :             :  * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
       3                 :             :  */
       4                 :             : 
       5                 :             : /*
       6                 :             :  * ====================================================
       7                 :             :  * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
       8                 :             :  *
       9                 :             :  * Developed at SunPro, a Sun Microsystems, Inc. business.
      10                 :             :  * Permission to use, copy, modify, and distribute this
      11                 :             :  * software is freely granted, provided that this notice
      12                 :             :  * is preserved.
      13                 :             :  * ====================================================
      14                 :             :  */
      15                 :             : 
      16                 :             : #include "cdefs-compat.h"
      17                 :             : //__FBSDID("$FreeBSD: src/lib/msun/src/e_hypotf.c,v 1.14 2011/10/15 07:00:28 das Exp $");
      18                 :             : 
      19                 :             : #include <openlibm_math.h>
      20                 :             : 
      21                 :             : #include "math_private.h"
      22                 :             : 
      23                 :             : OLM_DLLEXPORT float
      24                 :          20 : __ieee754_hypotf(float x, float y)
      25                 :             : {
      26                 :             :         float a,b,t1,t2,y1,y2,w;
      27                 :             :         int32_t j,k,ha,hb;
      28                 :             : 
      29                 :          20 :         GET_FLOAT_WORD(ha,x);
      30                 :          20 :         ha &= 0x7fffffff;
      31                 :          20 :         GET_FLOAT_WORD(hb,y);
      32                 :          20 :         hb &= 0x7fffffff;
      33         [ +  + ]:          20 :         if(hb > ha) {a=y;b=x;j=ha; ha=hb;hb=j;} else {a=x;b=y;}
      34                 :          20 :         a = fabsf(a);
      35                 :          20 :         b = fabsf(b);
      36         [ +  + ]:          20 :         if((ha-hb)>0xf000000) {return a+b;} /* x/y > 2**30 */
      37                 :          15 :         k=0;
      38         [ +  + ]:          15 :         if(ha > 0x58800000) {        /* a>2**50 */
      39         [ +  - ]:           5 :            if(ha >= 0x7f800000) {    /* Inf or NaN */
      40                 :             :                /* Use original arg order iff result is NaN; quieten sNaNs. */
      41                 :           5 :                w = fabsf(x+0.0F)-fabsf(y+0.0F);
      42         [ -  + ]:           5 :                if(ha == 0x7f800000) w = a;
      43         [ +  + ]:           5 :                if(hb == 0x7f800000) w = b;
      44                 :           5 :                return w;
      45                 :             :            }
      46                 :             :            /* scale a and b by 2**-68 */
      47                 :           0 :            ha -= 0x22000000; hb -= 0x22000000;  k += 68;
      48                 :           0 :            SET_FLOAT_WORD(a,ha);
      49                 :           0 :            SET_FLOAT_WORD(b,hb);
      50                 :             :         }
      51         [ -  + ]:          10 :         if(hb < 0x26800000) {        /* b < 2**-50 */
      52         [ #  # ]:           0 :             if(hb <= 0x007fffff) {   /* subnormal b or 0 */
      53         [ #  # ]:           0 :                 if(hb==0) return a;
      54                 :           0 :                 SET_FLOAT_WORD(t1,0x7e800000);  /* t1=2^126 */
      55                 :           0 :                 b *= t1;
      56                 :           0 :                 a *= t1;
      57                 :           0 :                 k -= 126;
      58                 :             :             } else {            /* scale a and b by 2^68 */
      59                 :           0 :                 ha += 0x22000000;       /* a *= 2^68 */
      60                 :           0 :                 hb += 0x22000000;       /* b *= 2^68 */
      61                 :           0 :                 k -= 68;
      62                 :           0 :                 SET_FLOAT_WORD(a,ha);
      63                 :           0 :                 SET_FLOAT_WORD(b,hb);
      64                 :             :             }
      65                 :             :         }
      66                 :             :     /* medium size a and b */
      67                 :          10 :         w = a-b;
      68         [ +  + ]:          10 :         if (w>b) {
      69                 :           9 :             SET_FLOAT_WORD(t1,ha&0xfffff000);
      70                 :           9 :             t2 = a-t1;
      71                 :           9 :             w  = __ieee754_sqrtf(t1*t1-(b*(-b)-t2*(a+t1)));
      72                 :             :         } else {
      73                 :           1 :             a  = a+a;
      74                 :           1 :             SET_FLOAT_WORD(y1,hb&0xfffff000);
      75                 :           1 :             y2 = b - y1;
      76                 :           1 :             SET_FLOAT_WORD(t1,(ha+0x00800000)&0xfffff000);
      77                 :           1 :             t2 = a - t1;
      78                 :           1 :             w  = __ieee754_sqrtf(t1*y1-(w*(-w)-(t1*y2+t2*b)));
      79                 :             :         }
      80         [ -  + ]:          10 :         if(k!=0) {
      81                 :           0 :             SET_FLOAT_WORD(t1,0x3f800000+(k<<23));
      82                 :           0 :             return t1*w;
      83                 :          10 :         } else return w;
      84                 :             : }
        

Generated by: LCOV version 2.0-115.g950771e