Byte order and ByteArray conversions
Lex Spoon
lex at cc.gatech.edu
Sun Oct 31 12:38:43 UTC 1999
If you know the endian-ness you want, you can use nextNumber:put: and
nextLittleEndianNumber:put: to write out integers in big endian or
little endian. So that would probably be the inverse of the methods you
were looking for. You can read them back with nextNumber: and
nextLittleEndianNumber:.
But why would knowing the machine's ordering matter, unless you are
doing primitives? Maybe if you post a higher-level view of what you are
trying to do, someone will have a more helpful response. I tend to like
the fact that I don't have to think about endianness :)
Lex
"David T. Lewis" <lewis at mail.msen.com> wrote:
>
> I'm sure I'm missing something obvious, but I'd like to be able to
convert
> integers to and from byte arrays in native machine byte ordering,
without
> resorting to a new primitive.
>
> 1) Does Squeak know the byte order convention of the hardware it's
running
> on? I can't find any method to query for this.
>
> 2) Class ByteArray knows how to convert itself into integers, given
that
> you can tell it the answer to question 1. Is there any existing
method
> for converting an integer into a four byte array?
>
> Thanks.
More information about the Squeak-dev
mailing list
|