(root)/
glibc-2.38/
sysdeps/
ieee754/
flt-32/
s_logbf.c
       1  /* s_logbf.c -- float version of s_logb.c.
       2   */
       3  
       4  /*
       5   * ====================================================
       6   * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
       7   *
       8   * Developed at SunPro, 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  #include <math.h>
      16  #include <math_private.h>
      17  #include <libm-alias-float.h>
      18  #include <fix-int-fp-convert-zero.h>
      19  #include <math-use-builtins.h>
      20  
      21  float
      22  __logbf (float x)
      23  {
      24  #if USE_LOGBF_BUILTIN
      25    return __builtin_logbf (x);
      26  #else
      27    int32_t ix, rix;
      28  
      29    GET_FLOAT_WORD (ix, x);
      30    ix &= 0x7fffffff;		/* high |x| */
      31    if (ix == 0)
      32      return (float) -1.0 / fabsf (x);
      33    if (ix >= 0x7f800000)
      34      return x * x;
      35    if (__glibc_unlikely ((rix = ix >> 23) == 0))
      36      {
      37        /* POSIX specifies that denormal number is treated as
      38           though it were normalized.  */
      39        rix -= __builtin_clz (ix) - 9;
      40      }
      41    if (FIX_INT_FP_CONVERT_ZERO && rix == 127)
      42      return 0.0f;
      43    return (float) (rix - 127);
      44  #endif /* ! USE_LOGBF_BUILTIN */
      45  }
      46  libm_alias_float (__logb, logb)