decode {dst} | R Documentation |
Find the value in base 10 of a number coded in another base
Description
The aplDecode
function of the project APL in R (https://rpubs.com/deleeuw/158476) has been adapted to follow the standard implementation of the APL decode
function.
Usage
decode(base, ind)
Arguments
base |
A scalar or a numeric vector which describes the number system in which the data is coded. |
ind |
The value to decode represented by a numeric vector in the |
Details
If the base value is a number system, e.g. base 2, we need only to enter it as a scalar, which is then processed to match the length of the expression to decode. If length(ind)
is less than length(base)
, zeroes are added to the left of the vector ind
to match the length of the two vectors. And vice-versa.
Value
A scalar representing the conversion of the coded number ind
to its decimal representation.
Author(s)
Claude Boivin
References
Jan de Leeuw and Masanao Yajima (March 07, 2016) APL in R (Version 009), Source code. https://rpubs.com/deleeuw/158476
L. Gilman and A. J. Rose.(1974): APL an Interactive Approach, Second Edition, John Wiley, New York.
APL 68000 Level II language manual. MicroAPL Ltd. 1990.
Examples
decode(c(2,2,2,2), c(1,0,1,1)) # Find the base 10 value of the base 2 number 1011.
decode(2, c(1,0,1,1)) # left argument is extended to vector c(2,2,2,2)
decode(c(365,24,60), c(2,1,57)) # transform 2 days 1 h 57 min in minutes
decode(c(365,24,60), c(1,57)) # right vector extended
decode(c(24,60), c(2,1,57)) # left vector extended
decode(1.5, c(1,2,3)) # polynomial 1*x^2 +2*x +3 evaluated at x=1.5