NumericConstants            package:base            R Documentation

_N_u_m_e_r_i_c _C_o_n_s_t_a_n_t_s

_D_e_s_c_r_i_p_t_i_o_n:

     How R parses numeric constants.

_D_e_t_a_i_l_s:

     R parses numeric constants in its input in a very similar way to C
     floating-point constants.

     'Inf' and 'NaN' are numeric constants (with 'typeof(.) "double"').
      All other numeric constants start with a digit or period.

     Hexadecimal constants start with '0x' or '0X' followed by a
     non-empty sequence from '0-9 a-f A-F' which is interpreted as a
     hexadecimal number ('"double"', not '"integer"').

     Decimal constants consists of a nonempty sequence of digits
     possibly containing a period (the decimal point), optionally
     followed by a decimal exponent.  A decimal exponent consists of an
     'E' or 'e' followed by an optional plus or minus sign followed by
     a non-empty sequence of digits, and indicates multiplication by a
     power of ten.

     A numeric constant immediately followed by 'i' is regarded as an
     imaginary complex number.

     An numeric constant immediately followed by 'L' is regarded as an
     'integer' number when possible (and with a warning if it contains
     a '"."').

     Only the ASCII digits 0-9 are recognized as digits, even in
     languages which have other representations of digits. The 'decimal
     separator' is always a period and never a comma.

     Note that a leading plus or minus is not part of numeric constant
     but a unary operator applied to the constant.

_S_e_e _A_l_s_o:

     'Syntax'.

     'Quotes' for the parsing of character constants,

_E_x_a_m_p_l_e_s:

     2.1
     typeof(2)
     sqrt(1i) # remember elementary math?
     utils::str(0xA0)
     identical(1L, as.integer(1))

     ## You can combine the "0x" prefix with the "L" suffix :
     identical(0xFL, as.integer(15)) # (with a regard to Fritz :-)

