[Cuis] VM Bug
Juan Vuletich
juan at jvuletich.org
Fri Feb 22 06:20:54 CST 2013
Hi Ken,
On 2/22/2013 2:04 AM, Ken Dickey wrote:
> I have been using Pharo-2.0's one-click cog VM with Pharo.
>
> There appears to be a bug in ShortIntegerArray on Linux (not tested on other platforms) such that you can't store 16-bit values iff the high bit is set.
>
> Not a problem for most of you, but I was using ShortIntegerArray-s to hold Unicode code points.
>
> http://code.google.com/p/pharo/issues/detail?id=7569
>
> FYI,
> -KenD
Cuis with Cog on my Mac shows same behavior. So I digged a little bit.
It is not a bug. ShortIntegerArray handles 16-bit unsigned integers. I
corrected the class comment. I.e.:
"ShortIntegerArray : unsigned"
sia := ShortIntegerArray new: 8 withAll: 0.
sia at: 1 put: 16r8421. "fails"
sia at: 1 put: -16r8000. "ok"
sia at: 1.
"IntegerArray : signed"
ia := IntegerArray new: 8 withAll: 0.
ia at: 1 put: 16r84210000. "Converts to negative"
ia at: 1.
ia at: 1 put: -16r80000000. "ok"
ia at: 1.
"WordArray: unsigned"
wa := WordArray new: 8 withAll: 0.
wa at: 1 put: 16r8421. "ok"
wa := WordArray new: 8 withAll: 0.
wa at: 1 put: -1.
Note that WordArray stores unsigned numbers, but the primitives handle
signed. If you want unsigned 16 bit, I'd rather add #unsignedAt: and
#unsignedAt:put: to ShortIntegerArray, doing a conversion like WordArray
does.
Cheers,
Juan Vuletich
More information about the Cuis
mailing list