3 ms·
This code doesn't make sense. 123.digits # => [3, 2, 1]
by proyb2 10y ago
This code doesn't make sense.
123.digits # => [3, 2, 1]
- gollahon 10y agoUsually when I've seen digits indexed in a number it occurs from right to left (certainly in binary contexts--bit 0 is the least significant bit and bit 31 is the the most significant bit in a 32 bit integer). So, 123.digits[0] means the least significant digit, 3, whereas 123.digits[2] would give you 1, the most significant digit.
- pmarreck 10y agoThe importance of the parts of a number matter in order of https://en.wikipedia.org/wiki/Significant_figures https://en.wikipedia.org/wiki/Significant_figures So this ordering is least to most significant.