[Gambas-user] Endianness issue with Streams ?

Laurent Carlier lordheavym at gmail.com
Wed Feb 7 14:20:57 CET 2024


Le mercredi 7 février 2024, 14:06:28 UTC+1 Benoît Minisini a écrit :
> Le 07/02/2024 à 13:59, Laurent Carlier a écrit :
> > While reading data from a file using Read function and changing endianness
> > i found a somehow strange behavior.
> > 
> > ----8<-----
> > 
> >    Dim $iValue As Integer
> >    Dim oFitFile As File
> >    
> >    oFitFile = Open "toto" For Read
> >    $iValue = Read #oFitFile As Short
> >    Print Hex$($iValue), $iValue
> > 
> > ---->8-----
> > 
> > Setting ByteOrder as Little endian gives:
> > 5E9     1513
> > Setting ByteOrder as Big endian gives:
> > FFFFFFFFFFFFE905        -5883
> > 
> > 
> > So is it expected or is it a bug ?
> 
> What's strange?

Ok, so it's the expected behavior :) Thanks. I thought hex representation 
should be truncated to 4 digits automatically as it's a short value (2 bytes).

Thanks for the clarification.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20240207/0afad60c/attachment.sig>


More information about the User mailing list