Bug? ByteConverter.LittleEndian

dilettante

Active Member
Licensed User
Longtime User
The docs say:
Gets or sets the endian-ness of byte conversions to and from other primitive values.
The default for Android is Big_Endian, Windows PCs are Little_Endian.

However:
  1. In B4J (Windows x86) the value returns false by default and it should be true.
  2. The Android default should depend on the platform (ARM vs. x86), if it doesn't already.
  3. I assume that if you could ever get a B4J program installed to run on an ARM-based Win8 machine then it would also need to default to false.
  4. If you ran a B4J program on Linux-on-ARM (far from rare now) it would need to default to false.
By "need to" I mean it is often necessary to be able to determine what platform endianness you have at runtime in order to do proper mapping between host byte order and network byte order for a vast number of Internet protocols.

Frankly we might be better off if the Socket library provided methods such as htonl(), ntohl(), and friends as one would normally expect.

But perhaps I am missing something here, either the intent of this Property or my attempted usage of it.
 

dilettante

Active Member
Licensed User
Longtime User
The version of ByteConverter that I have reports its version as 1.1, not 1.10 as stated in the docs. However I realize that it reports this as a Double which can lead to a lot of confusion. Maybe I should assume that the "1.1" release (if any) reported 1.01?
 

dilettante

Active Member
Licensed User
Longtime User
You are right of course.

Ensuring network byte order when implementing Internet protocols and binary data formats would be the main uses.

I was thinking about it incorrectly, imagining a need to flip back and forth between endianness settings to convert to/from network byte order. Since the operation is symmetric you just let the library deal with the local platform's actual multibyte number ordering.
 
Top