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 -- Ken [dot] Dickey [at] whidbey [dot] com _______________________________________________ Cuis mailing list [hidden email] http://jvuletich.org/mailman/listinfo/cuis_jvuletich.org
-KenD
|
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 _______________________________________________ Cuis mailing list [hidden email] http://jvuletich.org/mailman/listinfo/cuis_jvuletich.org |
On Fri, 22 Feb 2013 09:20:54 -0300
Juan Vuletich <[hidden email]> wrote: > 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. Yes. I want to store all 16 bits. Do whatever is the sensible thing. The comment in #at:put: is definitely at odds with what the primitives do. My personal preference is for unsigned byte, word, and long storage to have better naming (e.g. U8Array, U16Array, U32Array with #at:put: storing unsigned integers to 16rFF*) and have these subclassed for (S8Array, S16Array, S32Array) with #at:put: expecting signed integers of the proper size. Number implementations are way too complex and should be explained better for beginners. Thanks for the digging, -KenD -- Ken [dot] Dickey [at] whidbey [dot] com _______________________________________________ Cuis mailing list [hidden email] http://jvuletich.org/mailman/listinfo/cuis_jvuletich.org
-KenD
|
Hi Ken,
On 2/22/2013 12:56 PM, Ken Dickey wrote: > On Fri, 22 Feb 2013 09:20:54 -0300 > Juan Vuletich<[hidden email]> wrote: > >> 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. > Yes. I want to store all 16 bits. Do whatever is the sensible thing. I added new protocol to ShortIntegerArray and enhanced comments in this and related classes. Update is at GitHub. > The comment in #at:put: is definitely at odds with what the primitives do. > > My personal preference is for unsigned byte, word, and long storage to have better naming (e.g. U8Array, U16Array, U32Array with #at:put: storing unsigned integers to 16rFF*) and have these subclassed for (S8Array, S16Array, S32Array) with #at:put: expecting signed integers of the proper size. Sounds reasonable. Didn't implement this, though. > Number implementations are way too complex and should be explained better for beginners. > > Thanks for the digging, > -KenD Cheers, Juan Vuletich _______________________________________________ Cuis mailing list [hidden email] http://jvuletich.org/mailman/listinfo/cuis_jvuletich.org |
Free forum by Nabble | Edit this page |