[Q][Smalltalk][hex] converting binary to hex
Bob Arning
arning at charm.net
Tue Mar 19 14:41:52 UTC 2002
On Tue, 19 Mar 2002 07:37:05 -0700 "Ken G. Brown" <kbrown at tnc.ab.ca> wrote:
>hex := '0123456789ABCDEF'.
> aByteArray do: [:each | aStream nextPut: (hex at: each // 256 +
>1). aStream nextPut: (hex at: each \\ 256 + 1)].
>
>It appears to break when the byte value gets bigger than 15. Or did I
>do something incorrectly?
That should be "// 16" and "\\ 16" instead of 256. The first example Richard gave had it right, but the second led you astray.
Cheers,
Bob
More information about the Squeak-dev
mailing list
|