ubyte[4] to int

Jonathan M Davis newsgroup.d at jmdavisprog.com
Thu Feb 15 18:55:06 UTC 2018


On Thursday, February 15, 2018 18:47:16 Kyle via Digitalmars-d-learn wrote:
> I was thinking that the client could determine its own endianness
> and either convert the passed int to the other if big, or leave
> it alone if little, then send it to the server as little-endian
> at that point.

nativeToBigEndian and nativeToLittleEndian convert integral values to the
target endianness, taking the native endianness into account. So, if what
you want to do is take an int and convert it to ubyte[4], then both of those
functions will do that for you. It's just a question of what the target
endianness is either. Either way, the endianness of the machine itself will
be properly taken into account when that conversion is done, and you don't
have to worry about it.

- Jonathan M Davis



More information about the Digitalmars-d-learn mailing list