decode: Decode

Description Usage Arguments Value Examples

View source: R/encoding.R

Description

Decode an integer into a base-b array with n digits. Note that the base b must be provided, but the number of digits n is optional. If it is provided then the decoded state will have exactly that many elements. If n is not provided, the length of the decoded state is as small as possible.

Usage

1
decode(encoding, b, n = NA)

Arguments

encoding

Numeric of the encoded state.

b

Numeric giving the desired base.

n

Numeric giving the desired number of digits.

Value

Vector giving the decoded state.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
# The provided encoded state is decoded using the big-endian
# encoding scheme.
decode(2, b = 2, n = 2) # [1, 0]
decode(6, b = 2, n = 3) # [1, 1, 0]
decode(6, b = 3, n = 2) # [2, 0]

# If n is not provided, the length of the decoded state
# is as small as possible
decode(1, b = 2) # [1]
decode(1, b = 3) # [1]
decode(3, b = 2) # [1, 1]
decode(3, b = 3) # [1, 0]
decode(3, b = 4) # [3]

rinform documentation built on April 1, 2018, 12:12 p.m.