Endianess

This is an old ar­ti­cle from 2013. I was a kid. I learned a lot since then, so please do think twice when tak­ing ad­vice from me as a kid.

I re­cent­ly spent 5 hours try­ing to fig­ure out why my maps I write from an own made “tiled” plug­in (Ja­va) aren’t bee­ing read prop­er­ly in my nin­jarun game (C), al­ready know­ing all along it must be be­cause of the en­di­aness (But I’m al­ways lazy to mess with the ac­tu­al bits them­selves, so I spent all my time googling for proof, be­fore I ac­tu­al­ly start re­vers­ing byte or­ders).

Ja­va stores it’s stuff as big-en­di­an **where­as c will try to load it as **lit­tle-en­di­an.

So, how do you cope with this prob­lem? Sim­plest: Save the file in Ja­va as lit­tle-en­di­an. This can be very eas­i­ly ac­com­plished by us­ing Byte­Buffers, and set­ting us­ing .order(ByteOrder.LITTLE_ENDIAN)

This post was im­port­ed from tum­blr

Tumblr

Archived blog posts from squareys.tum­blr.com.