Do I really need littleendian::

BlitzMax Forums/BlitzMax Programming/Do I really need littleendian::

Grey Alien(Posted 2007) [#1]
Just building a Universal Binary today and this tutorial:

http://www.blitzbasic.com/Community/posts.php?topic=65180

says I need to use littleendian:: before Readfile and stream commands. Well I'm reading in strings from text files so it shouldn't matter right? It only matters if I was reading in Integers from a data file made on a different machine yes? I am reading in some integers (high scores etc) but that file is generated on each machine when the game is first run so I assume it's safe (it seems to work fine).


Dreamora(Posted 2007) [#2]
The endianess affects even bytes so single characters.

But I thought since 1.24 or the like (with the addition of the PPC and Intel OSX compiler directives) the endianess should be handled automatically


FlameDuck(Posted 2007) [#3]
says I need to use littleendian:: before Readfile and stream commands.
It doesn't really matter which you use, as long as you use it consistently.

Well I'm reading in strings from text files so it shouldn't matter right?
It depends on what format the text is in. Since most (non-ASCII-7) text formats use bitstreams, I would have thought it made more sense conceptually to use a bigendian format - although in the long run the difference is probably negligible.

The endianess affects even bytes so single characters.
No it doesn't.


JazzieB(Posted 2007) [#4]
As a little side note, if you're using Banks then you will also need to bear in mind that the bytes of a long (and other multi-byte formats) are stored the opposite way around on a PPC based system. The endianess setting doesn't affect the Poke/Peek commands.

I had to make use of alternative functions when reading in level data created on my PC, because I need the same files to be read no matter what system they were originally created on.


Grey Alien(Posted 2007) [#5]
OK, thanks. I'm not using Banks so that's OK, and I've stuck to not using littleendian so it should be OK. The game seems to work fine, but I'll be converting some games more soon and I wondered what I should look out for.

JazzieB: yeah luckily the data files are just text files not a load of ints so I'm OK at the moment until future games when I use may use that format.