Hi Henrik,
On Jun 1, 2017, at 7:10 AM, Henrik Sperre Johansen <henrik.s.johansen@veloxit.no> wrote:
For a solution that works without change in 32/64 migration, one could use self class maxVal digitLength
... but there's quite a bit of calculation in digitLength.
Speaking of excessive calculation; SmallInteger class >> startUp: isImageStarting "The image is either being newly started (isImageStarting is true), or it's just been snapshotted. If this has just been a snapshot, skip all the startup stuff." | next val | isImageStarting ifFalse: [^self]. val := -32768. "Assume at least 16 bits" [next := val + val. next class == self] whileTrue: [val := next]. minVal := val. maxVal := -1 - val
... really? If this actually runs on 64bit image startup, that's quite impressive!
This is hardly excessive :-). It only takes 45 or 46 iterations to discover the max 64-bit integer. The code is modeled on the Smalltalk-80 v 2 code that was on the original PARC Smalltalk tape which was there for 32-bit systems; the PARC Smalltalks were 16-bit. Squeak, and hence Pharo, derived from Smalltalk-80 v 1 and so didn't have this code. Cheers, Eliot