[Gambas-user] ¿bug? Error with Val function and hex values

Rafa Domenech rafadose at ...626...
Fri Mar 26 00:56:30 CET 2010


Hello,

I've a problem trying to convert a string in hex to decimal.
When I do this:
test = (Val("&H9000") AND 65535)
I obtain
test = -28672 (equals to 0xFFFFFFF9000)
and it should be
test = 36864 (0x9000)

And when I debug it step by step I obtain what you can see in this
screenshot.
[image: Pantallazo-1.png]
This example seems very stupid (and it is), I did it because I noticed that
this code
test = Val("&H" & TextBox1.Text)
didn't work fine with TextBox1.Text="9000" and maybe with other values. Then
I tried to "cut" with AND with &HFFFFF but it didn't work so I changed it to
its decimal conversion 65535 and now at least the debugger shows the correct
value but it doesn't asign it to test.

I'm using Gambas 2.20.2  in Ubuntu 9.10 with 2.6.31-20-generic kernell

Thankyou

Rafa
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Pantallazo-1.png
Type: image/png
Size: 18922 bytes
Desc: not available
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20100326/a5ae53c0/attachment.png>


More information about the User mailing list