Is this a buglet? (SmallInteger>>printString related)
nicolas cellier
ncellier at ifrance.com
Fri Jun 1 11:19:46 UTC 2007
Göran Krampe <goran <at> krampe.se> writes:
>
> After messing with SmallInteger>>decimalDigitLength and noticing that
> '1000 log truncated' returns the wrong answer I ended up chasing down
> base-10 log algorithms. Found this nice source of tricks:
>
> http://www.hackersdelight.org/HDcode/ilog.c
>
> And based on code in there and the fact that nlz (number of leading zeros)
> can be computed using 'self asFloat exponent' I came up with this
> implementation of #floorLog for SmallIntegers. It still is not as fast as
> simpleminded comparisons as in decimalDigitLength though so it is not
> worth using. But it was fun to experiment."
>
Yes, this link is fun.
Also don't forget Smalltalk has #highBit,
a complement of nlz not involving Float.
Nicolas
More information about the Squeak-dev
mailing list
|