Posted: Tue Oct 28, 2014 9:44 pm Post subject: Integer storage in ERAM
So how is it done? For example, I know if I store "-3" in ERAM, it is stored as 2 bytes of 253 and 255 decimal.
My problem is I'm trying to convert those 2 bytes back to an integer in a VB program but it only seems to work for positive numbers. If a negative (as above) is stored, my VB code isn't happy at all.
I know this is a VB issue but knowing what to look for in ERAM would certainly help!
your VB is probably using longs and not integers ?
make a simple program, then watch the values in the Simulator. eram data is stored the same as sram data. LSB first.
you can do the same for your VB code. But you need to use something like peek() to get the memory position. My guess is that your VB code is storing integers as longs.
In such a case you need to check the sign bit (bit 15). and when it is set, make all leading bytes 255. _________________ Mark
Joined: 16 Jan 2006 Posts: 2483 Location: Queensland
Posted: Wed Oct 29, 2014 6:56 am Post subject:
Integer storage in VB is the same as in Bascom. So if you declare a variable as integer in VB, it will be rendered correctly, ie bytes stored as 253, 255 will render as "-3".
How are you actually storing the bytes you read from eram so VB can see them ? _________________ Adrian Jansen
Computer language is a framework for creativity
The integer is dimensioned as an eram integer and assigned a value.
I have since received a suggestion from a VB forum on how to fix my VB code, which I did. And all seems ok now. Thanks you guys for your inputs![/code]
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum