 Split - Maple Help

Bits

 Split
 split number into bit multiples Calling Sequence Split(number, options) Split(number, sbits, options) Parameters

 number - an integer sbits - (optional) positive integer number of bits to split on options - bits option Description

 • The Split command breaks the input number into a list of sbits bit length (default is 1) numbers, least significant bits first.

Put simply, the Split command converts a number into a list of the base 2^sbits digits.

 • The most common usage of this command would be for conversion of a number into its base-2 digits, but it could also be used, for example, to convert a number to octal or hex (see convert/octal or convert/hex).

The String command is closely related, but the output for that command is a string.

 • The option bits=n tells Split how many bits to consider in the split. Any bits in a higher position are simply ignored.

The number of bits can also be set via Settings.

 • The reverse operation, converting the digits to a number, is accomplished using the Join command. Examples

Convert to binary

 > $\mathrm{with}\left(\mathrm{Bits}\right):$
 > $\mathrm{Split}\left(255\right)$
 $\left[{1}{,}{1}{,}{1}{,}{1}{,}{1}{,}{1}{,}{1}{,}{1}\right]$ (1)
 > $\mathrm{Split}\left(255,2\right)$
 $\left[{3}{,}{3}{,}{3}{,}{3}\right]$ (2)

Convert to octal

 > $\mathrm{Split}\left(255,3\right)$
 $\left[{7}{,}{7}{,}{3}\right]$ (3)

Convert first 6 bits to octal

 > $\mathrm{Split}\left(255,3,\mathrm{bits}=6\right)$
 $\left[{7}{,}{7}\right]$ (4)

Convert first 32 bits to hex

 > $\mathrm{Split}\left(255,4,\mathrm{bits}=32\right)$
 $\left[{15}{,}{15}{,}{0}{,}{0}{,}{0}{,}{0}{,}{0}{,}{0}\right]$ (5)

To bits, then back to a number

 > $\mathrm{dig}≔\mathrm{Split}\left(395718860534\right)$
 ${\mathrm{dig}}{≔}\left[{0}{,}{1}{,}{1}{,}{0}{,}{1}{,}{1}{,}{1}{,}{1}{,}{0}{,}{1}{,}{1}{,}{1}{,}{1}{,}{0}{,}{0}{,}{1}{,}{0}{,}{1}{,}{1}{,}{1}{,}{0}{,}{1}{,}{0}{,}{1}{,}{0}{,}{1}{,}{0}{,}{0}{,}{0}{,}{1}{,}{0}{,}{0}{,}{0}{,}{0}{,}{1}{,}{1}{,}{1}{,}{0}{,}{1}\right]$ (6)
 > $\mathrm{num}≔\mathrm{Join}\left(\mathrm{dig}\right)$
 ${\mathrm{num}}{≔}{395718860534}$ (7)