Type Definition: 'R_xlen_t' and 'R_len_t'

#include <Rinternals.h>
R_xlen_t
R_len_t

Format

An object of class typedef of length 1.

Source

Declaration: src/include/Rinternals.h

C API

Long vectors:

typedef ptrdiff_t R_xlen_t;
define R_XLEN_T_MAX 4503599627370496

Short vectors:

typedef int R_len_t;
#define R_LEN_T_MAX INT_MAX

If long vectors are not supported on the current platform, then:

LONG_VECTOR_SUPPORT

is not defined and we have:

typedef int R_xlen_t;
define R_XLEN_T_MAX R_LEN_T_MAX

R API

library(base)

# Maximum length of a "short" vector ...
x <- seq_len(.Machine$integer.max)
xlen <- length(x) # integer; internally R_len_t

# ... before becoming a "long" vector
x <- seq_len(.Machine$integer.max + 1)
xlen <- length(x) # numeric; internally R_xlen_t