ilogb               package:ifultools               R Documentation

_I_n_t_e_g_e_r _t_r_u_n_c_a_t_i_o_n _o_f _l_o_g_b _o_u_t_p_u_t

_D_e_s_c_r_i_p_t_i_o_n:

     Calculates 'logb(x, base=base) + eps' where 'eps' is a
     user-supplied (small) value and converts the result ala
     'as.integer'. The purpose of this function is to avoid 'logb'
     variations between platforms. As an example, it is conceivable
     that 'logb(32, base=2)' on one platform could return a value of
     '5' while on another platform it could return a slightly smaller
     value, e.g., '4.999999999999999'. The difference is due to
     different compiler and platform-specific implementations of the
     S-PLUS or R languages. If 'logb' output is truncated (as is the
     case with 'as.integer(logb(x))') then the result may be
     unexpected, leading to intractable errors. By adding an
     appropriate and small value to 'logb(x)', subsequent truncation
     results in consistent value(s) across platforms.

_U_s_a_g_e:

     ilogb(x, base=2, eps=.Machine$double.eps * 1e9)

_A_r_g_u_m_e_n_t_s:

       x: a numeric or complex vector.

    base: a positive or complex number: the base with respect to which
          logarithms are computed. Default: '2'.

     eps: a small numeric value that is added to the 'logb' result
          prior to truncation via 'as.integer'. Default:
          '.Machine\$double.eps * 1e9'.

_V_a_l_u_e:

     a numeric scalar or vector containing the result.

_S_e_e _A_l_s_o:

     'logScale'.

_E_x_a_m_p_l_e_s:

     ## should return 3 
     ilogb(8 - .Machine$double.eps, base=2)

