Conversion from big endian to little endian

Blitz3D Forums/Blitz3D Programming/Conversion from big endian to little endian

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

You must also adjust by 65536 to simulate a signed 16-bit value.
Print ConvertSignedShort( $0200 )
Print ConvertSignedShort( $0100 )
Print ConvertSignedShort( $0000 )
Print ConvertSignedShort( $FFFF )
Print ConvertSignedShort( $FEFF )

WaitKey


Function ConvertSignedShort( ss )  ; bottom two bytes of an Int.

	ss = ( ( ss And $ff00 ) Shr 8 ) Or ( ( ss And $ff ) Shl 8 )

	If ss < $8000
		Return ss
	Else
		Return ss - $10000
	End If
	
End Function