Will this work?
function isbigendian()
unbox16(0x0001) == 256 ? true : false
end
or would endian tests & byte-swapping need to be implemented in C?
--Tim
julia> reinterpret(Uint16,uint8(1:2))[1]0x0201julia> reinterpret(Uint32,uint8(1:4))[1]0x04030201julia> reinterpret(Uint64,uint8(1:8))[1]0x0807060504030201
Here's it's more an issue of properly supporting particular image file types,
like UVF
(http://www.sci.utah.edu/devbuilds/workshop11/docs/GettingDataIntoImageVis3D.pdf),
which have a field that encodes the endian state used by the raw data stored on
disk. If someone were to acquire and store binary data on a big-endian
machine, it would have to be byteswapped before it would make any sense on a
little endian machine.
--Tim
>
> On Thu, Apr 5, 2012 at 3:31 PM, Stefan Karpinski
<ste...@karpinski.org>wrote:
> > Ah, someone has gotten into unbox and box features. These are very
> > low-level intrinsics that should *never* be called by code that's not
> > bootstrapping the julia system itself. What unboxN does is take a
> > first-class N-bit bitstype value and "convert" it into a non-first-class,
> > unboxed chunk of
> > bits<http://en.wikipedia.org/wiki/Boxing_(computer_science)#Boxing>in
OK, when I wrote that last message I was trying to catch a train. Now I've
actually looked at it :-). Interesting indeed, and not what I expected!
Should the converse apply when you write a file? E.g., always write in little
endian format and say so, rather than writing in native order? (I'm sure this
is 102% obvious to you, but if you write in native order, then you'd better
test the endian status of the machine you're on.)
Thanks for the pointer.
--Tim
>
On Thursday, April 05, 2012 05:28:48 pm Stefan Karpinski wrote:
> Right, right. This is the distinction that Rob Pike makes: it is important
> to know what the endianness of a data stream is, but not what the
> endianness of your machine is. That's a subtle distinction, but an
> important one. That being said, I've certainly written a lot of code that
> uses ntoh and hton functions.OK, when I wrote that last message I was trying to catch a train. Now I've
actually looked at it :-). Interesting indeed, and not what I expected!Should the converse apply when you write a file? E.g., always write in little
endian format and say so, rather than writing in native order? (I'm sure this
is 102% obvious to you, but if you write in native order, then you'd better
test the endian status of the machine you're on.)