LSB MSB da variabile Word (Int16)

Ho creato una funzione che mi converte un valore int16 in 2 byte distinti.

Il programma creato il seguente:

Dim Value as int16 Dim HiByte, LoByte as byte Hibyte = integer.FromBinary(leftb(bin(Value),8).ToText) Lobyte = Value and 255

Esiste un sistema pi pulito per ottenere il byte pi significativo senza conversione in stringa “binaria” ?
Se dovessi scomporre una variabile con pi byte quale sarebbe la soluzione migliore ?

[code] Dim i As Int16 = &h8234
Dim ui As Uint16 = &h8234
Dim hb, lb As byte

// For an Int16 demands a trick
hb = ((i \ &h10) and &hFF0)\&h10 // Math trick used to remove an error from negative numbers
lb = i and &hFF
System.DebugLog "Int16: “+hb.ToHex+” "+ lb.ToHex

// For an UInt16 it’s direct
hb = ui \ &h100
lb = ui and &hFF
System.DebugLog "Uint16: “+hb.ToHex+” "+ lb.ToHex
[/code]

Interestingly this Int16.ToHex() is broken

Dim i As Int16 = &h8234 MsgBox i.ToHex // We see 4 instead of 8234, at least in Xojo 2014 r3.2