banks and endians

BlitzMax Forums/BlitzMax Programming/banks and endians

v1 and v2 is not equal if this code is executed on a mac:
local b:tbank = loadbank("littleendian::file.bin")
local v1:int = peekint( b, 0 )

local s:tstream = readfile("littleendian::file.bin")
local v2:int = readint( s )

v2 contains the correct value.
Is this the way it should behave? Was unable to find anything about it in the manual.
I know that loadbank cannot convert the data it loads, but it should at least set a flag or something so readint and friends converts the data.

Testing on a PC I get this behaviour:

The value returned by ReadInt changes with the endianness.
LoadBank ignores bigendian/littleendian, as it must. PeekInt just returns 'raw data'.

That seems correct to me. Peek is a lower level function that Read.
It would just feel wrong to have Peek automatically change values based on endianness.

It would just feel wrong to have Peek automatically change values based on endianness.

But what if I want to load a binary file in little endian format into a bank on a mac and read stuff? Like I want to do now? :)

I'm using streams now so this isn't a problem for me. Just wanted to report what I thought was a bug.

Hi,

This is correct behaviour.

LoadBank uses the low level stream 'read' function, which is not affected by endianness.