Convert Binary-Integer in String to real Integer

Hello everyone,

how to convert a data type packed in a string back to its original type?

For example
The first 8 bytes of a string contain a UInt32 number:
B90D 0000 0000 0000 [Binary]

How can I make 3513 [Dec] out of it?

Here’s what I tried to do:

Dim mbc As MemoryBlock = StringRepresentationOfInteger
Dim mb As New Xojo.Core.MutableMemoryBlock( mbc, mbc.Size )
Dim tmp As UInt32
tmp = mb.UInt32Value(0)

It works, but is that the best way?

That looks more like an int64 to me (since every hex digit is 4 bits)
other than that endianess may be relevant but this is a reasonable way to do this

the conversion from old memory block to new memory block is an extra unnecessary step.

[quote=359098:@Norman Palardy]That looks more like an int64 to me (since every hex digit is 4 bits)
other than that endianess may be relevant but this is a reasonable way to do this[/quote]

Your’re right. It’s UInt64, my fault.

You’re right. This works too:

Dim mbc As MemoryBlock = StringRepresentationOfInteger
Dim tmp As UInt64
tmp = mbc.UInt64Value(0)