number_tobary — Decompose a number into arbitrary basis.
digits = number_tobary ( n ) digits = number_tobary ( n , basis ) digits = number_tobary ( n , basis , order ) digits = number_tobary ( n , basis , order , p )
a 1x1 matrix of floating point integers, the integer to decompose, must be positive
a 1x1 matrix of floating point integers, the basis, must be positive, (default basis=2)
a 1x1 matrix of strings, the order (default order="littleendian")
a 1x1 matrix of floating point integers, the number of digits on output (default p=0)
a p-by-1 matrix of floating point integers, the digits.
Returns a column matrix of digits of the decomposition of n in base b, i.e. decompose n as
n = d(1) b^(p-1) + d(2) b^(p-2) + ... + d(p) b^0.
This order is little endian order since the last digit is associated with b^0. If "bigendian" order is chosen, returns the digits d so that
n = d(1) b^0 + d(2) b^1 + ... + d(p) b^(p-1),
i.e. the last digit is associated with b^(p-1).
If p=0, returns the least possible number of digits. If p is a positive integer, returns p digits. If the integer cannot be stored in p digits, generates an error. If the integer is larger than p digits, pad with zeros.