Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

toBinary

Binary representation of non-negative integer


Description

A non-negative integer is represented as a binary number. The digits, 0 or 1, of this number are returned in a vector.

Usage

toBinary(n, k = ceiling(logb(n+1,base=2)))

Arguments

n

a non-negative integers

k

number of digits to be returned.

Value

A vector of length k. The first element is the least significant digit.

Author(s)

A.I. McLeod

Examples

toBinary(63)
toBinary(64)
#sometimes we want to pad result with 'leading' 0's
toBinary(63, k=20)
toBinary(64, k=20)

FitAR

Subset AR Model Fitting

v1.94
GPL (>= 2)
Authors
A.I. McLeod, Ying Zhang and Changjiang Xu
Initial release
2013-03-15

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.