digits

convert a number into an array of digits or an array of digits back into a number


Parameters

digits number :integer :block

Attributes

base:integeruse given based (default: 10)

Returns

  • :block

Examples

copy
digits 123 ; => [1 2 3] digits [1 2 3] ; => 123 digits 0 ; => [0] digits neg 12345 ; => [1 2 3 4 5] ; digits 1231231231231231231231231231023 ; => [1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 0 2 3]

Related