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

             Branch data     Line data    Source code
       1                 :             : /* @(#)s_nextafter.c 5.1 93/09/24 */
       2                 :             : /*
       3                 :             :  * ====================================================
       4                 :             :  * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
       5                 :             :  *
       6                 :             :  * Developed at SunPro, a Sun Microsystems, Inc. business.
       7                 :             :  * Permission to use, copy, modify, and distribute this
       8                 :             :  * software is freely granted, provided that this notice
       9                 :             :  * is preserved.
      10                 :             :  * ====================================================
      11                 :             :  */
      12                 :             : 
      13                 :             : #include "cdefs-compat.h"
      14                 :             : //__FBSDID("$FreeBSD: src/lib/msun/src/s_nexttoward.c,v 1.3 2011/02/10 07:38:13 das Exp $");
      15                 :             : 
      16                 :             : /*
      17                 :             :  * We assume that a long double has a 15-bit exponent.  On systems
      18                 :             :  * where long double is the same as double, nexttoward() is an alias
      19                 :             :  * for nextafter(), so we don't use this routine.
      20                 :             :  */
      21                 :             : 
      22                 :             : #include <float.h>
      23                 :             : #include <openlibm_math.h>
      24                 :             : 
      25                 :             : #include "fpmath.h"
      26                 :             : #include "math_private.h"
      27                 :             : 
      28                 :             : #if LDBL_MAX_EXP != 0x4000
      29                 :             : #error "Unsupported long double format"
      30                 :             : #endif
      31                 :             : 
      32                 :             : OLM_DLLEXPORT double
      33                 :           0 : nexttoward(double x, long double y)
      34                 :             : {
      35                 :             :         union IEEEl2bits uy;
      36                 :             :         volatile double t;
      37                 :             :         int32_t hx,ix;
      38                 :             :         u_int32_t lx;
      39                 :             : 
      40                 :           0 :         EXTRACT_WORDS(hx,lx,x);
      41                 :           0 :         ix = hx&0x7fffffff;         /* |x| */
      42                 :           0 :         uy.e = y;
      43                 :             : 
      44   [ #  #  #  # ]:           0 :         if(((ix>=0x7ff00000)&&((ix-0x7ff00000)|lx)!=0) ||
      45         [ #  # ]:           0 :             (uy.bits.exp == 0x7fff &&
      46         [ #  # ]:           0 :              ((uy.bits.manh&~LDBL_NBIT)|uy.bits.manl) != 0))
      47                 :           0 :            return x+y;  /* x or y is nan */
      48         [ #  # ]:           0 :         if(x==y) return (double)y;              /* x=y, return y */
      49         [ #  # ]:           0 :         if(x==0.0) {
      50                 :           0 :             INSERT_WORDS(x,uy.bits.sign<<31,1);   /* return +-minsubnormal */
      51                 :           0 :             t = x*x;
      52         [ #  # ]:           0 :             if(t==x) return t; else return x;   /* raise underflow flag */
      53                 :             :         }
      54         [ #  # ]:           0 :         if((hx>0.0) ^ (x < y)) {                  /* x -= ulp */
      55         [ #  # ]:           0 :             if(lx==0) hx -= 1;
      56                 :           0 :             lx -= 1;
      57                 :             :         } else {                                /* x += ulp */
      58                 :           0 :             lx += 1;
      59         [ #  # ]:           0 :             if(lx==0) hx += 1;
      60                 :             :         }
      61                 :           0 :         ix = hx&0x7ff00000;
      62         [ #  # ]:           0 :         if(ix>=0x7ff00000) return x+x;       /* overflow  */
      63         [ #  # ]:           0 :         if(ix<0x00100000) {          /* underflow */
      64                 :           0 :             t = x*x;
      65         [ #  # ]:           0 :             if(t!=x) {          /* raise underflow flag */
      66                 :           0 :                 INSERT_WORDS(x,hx,lx);
      67                 :           0 :                 return x;
      68                 :             :             }
      69                 :             :         }
      70                 :           0 :         INSERT_WORDS(x,hx,lx);
      71                 :           0 :         return x;
      72                 :             : }
        

Generated by: LCOV version 2.0-115.g950771e