Page 1 of 1

PostPosted: Wed Jul 03, 2002 4:12 am
by ggravier

<i>PocketC</i> doesn't support <b>unsigned</b> types. This is a big problem when doing things like crypto or system programming. Any easy workarounds?

Thanks in advance,

-- Gilles Gravier = = --
PGP Key ID: 0x8DE6D026 ICQ: 77488526
"Chastity is its own punishment." (Solomon Short) [David Gerrold]

PostPosted: Thu Jul 04, 2002 3:28 am
by jstadolnik
The integers in PocketC are 32 bit two's complement numbers. As such, the math should still work out fine, even though the numbers can get negetive.

For example: 0xffffffff is equal to both -1 and (2^32)-1, such that if you do -1 * 0xffffffff you should get -7 which is also 0xfffffff9 (clipped to 32 bits).

The only catch is that you can't print out 32 bit unsigned numbers without doing some hocus-pocus.

Then again, I may be smoking crack...


The PToolboxLib guy.

PostPosted: Mon Jul 29, 2002 4:14 pm
by Vigon
Dealing with serial comms and bit manipulations...
Several times had to use:
<pre id=code><font face=courier size=2 id=code>
if(var<0) var = var (plus) 256;
</font id=code></pre id=code>
to solve the problem of using var as counter or index.

I'm not proud of this solution anyway.

Note: (plus) is used because the plus symbol do not appear in the preview.