B4R Question INT to HEX

petr4ppc

Well-Known Member
Licensed User
Longtime User
Dear friends, please for advice:

Why I get from this code

B4X:
                Dim bc As ByteConverter
                Dim nr1() As Byte = bc.HexFromBytes(bc.IntsToBytes(Array As Int(1)))
                Dim nr2() As Byte = bc.HexFromBytes(bc.IntsToBytes(Array As Int(20)))
                Dim nr3() As Byte = bc.HexFromBytes(bc.IntsToBytes(Array As Int(1234)))

this result=
nr1=0100
nr2=1400
nr3=D204

but I must get
nr1=0001
nr2=0014
nr3=04D2

What I am doing wrong, please?
Thank you
p4ppc
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
B4X:
Private Sub AppStart
    Serial1.Initialize(115200)
    Log("AppStart")
    Dim bc As ByteConverter
    Dim b(2) As Byte
    Dim raf As RandomAccessFile
    raf.Initialize(b, False) 'big endian
    raf.WriteInt16(1, 0)
    Log(bc.HexFromBytes(b))
    raf.WriteInt16(20, 0)
    Log(bc.HexFromBytes(b))
    raf.WriteInt16(1234, 0)
    Log(bc.HexFromBytes(b))
End Sub
 
Upvote 0

petr4ppc

Well-Known Member
Licensed User
Longtime User
Dear Mr. Erel,

thank you very much for big help, it is functioned great,

Best regards
p4ppc
 
Upvote 0
Top