I get a "Cannot cast type: {Type=Double,Rank=1, RemoteObject=True} to: {Type=Double,Rank=0, RemoteObject=True}" on the dHeight = line, but can't see what I'm doing wrong, any help appreciated.
B4X:
Dim Height(5) as Byte
...
...
...
Dim BC As ByteConverter
Dim dHeight As Double
dHeight = BC.DoublesFromBytes(Height)
Dim Height(5) as Byte
...
...
...
Dim BC As ByteConverter
Dim dHeights() As Double
dHeights = BC.DoublesFromBytes(Height)
Dim dHeight As Double = dHeights(0)
Many thanks for the reply and it now compiles, but I'm not getting the right result.
Ok, so maybe I've misunderstood what DoublesFromBytes means.
I have a byte array with 5 bytes containing ASCI characters that represent a floating point number, say 34.1 (so 51,50,46,49,00) and I was assuming that it would convert this to a 4 byte numeric value representing the double value, but I get 0.0000 if I log it
Hi, yes I know that which is why I was thinking the function DoublesFromBytes would do the conversion. Apparently its StringFromBytes which must create a string representation of the double and then somehow assigning a string of a double to a double variable does the conversion. I get this with a constant but not with an variable. In other languages doing something like:
A ="12.3"
B = A
Where A is a string and B is a double wouldnt work.