[Pharo-project] digitAt: issue

Nicolas Cellier nicolas.cellier.aka.nice at gmail.com
Mon May 2 19:32:58 CEST 2011

You are perfectly right, digitus means finger in latin, so it
generally carries the notion of 10-base.

I guess #byteAt: was not selected because it was considered as an
implementation detail.
The implementation might as well switch to 16 or 32 bits "digits", and
you could still use generic code like
    1 to: self digitLength do: [:i | (self digitAt: i) doSomething ]
As long as you don't put any expectation on #digitAt: bit length...

Since plenty of optimization depending on #digitAt: returning a byte
have been added to the system - some by me :( - we shall better use
byteAt:, but it's hard to control how a living system evolves...


2011/5/2 Bernat Romagosa <tibabenfortlapalanca at gmail.com>:
> As intended, yes. But not as expected from what digit usually means (any of
> the arabic figures of 1 through 9 and 0. [3]).
> I guess that'd change the behavior of too many things, but IMHO byteAt:
> would suit much better what this method does.
> 2011/5/2 Eliot Miranda <eliot.miranda at gmail.com>
>> digitAt: answers a byte in an integer and so is working as intended.
>> Eliot (phone)
>> On May 2, 2011, at 2:13 AM, Bernat Romagosa
>> <tibabenfortlapalanca at gmail.com> wrote:
>> Hi, try to run the following:
>> (2 raisedTo: 100000) digitAt: 1
>> The expected result (if I understood what digitAt: should return) is 9,
>> but the message returns 0 instead. In fact, it returns 0 for any index.
>> Is this a bug or am I missunderstanding how digitAt: should work?
>> Cheers,
>> Bernat Romagosa.
>> p.s. My config is Pharo 1.2 with a 'Croquet Closure Cog VM [CoInterpreter
>> VMMaker-oscog.51]' on Debian Lenny.

More information about the Pharo-project mailing list