[ragel-users] Newbie problem with reading unsigned numbers

Neil Webster nwebster at biopeak.com
Wed Sep 2 17:10:32 UTC 2009

Hi Guys,

Please accept my apologies for the email clutter but I forgot the
attachment ....

On Wed, 2009-09-02 at 13:08 -0400, Neil Webster wrote:

> I am trying to create a reusable structure for reading in data from a
> binary data stream. I have attached a ragel file that demonstrates the
> problem I am having and would appreciate tips and advice on what I am
> doing wrong or better ways to go about solving the problem.
> I have defined Word8b, Word16b and Word32b to represent the blocks I
> will be reading from the data stream. The data is accumulated into a
> temporary variable (temp) and then assigned to the specific variable on
> exit from the appropriate machine. It works fine for small numbers but
> does strange things with numbers >127. It seems to be a problem with
> signed vs unsigned but I can't figure out what it is.
> What I expect
> a8 1 b8 ff a16 2 b16 fe a32 3 b32 fd
> What I get
> a8 1 b8 ffff a16 2 b16 fffe a32 3 b32 fffffffd 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.colm.net/pipermail/ragel-users/attachments/20090902/682311f0/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: demoIssue.rl
Type: text/x-csrc
Size: 1015 bytes
Desc: not available
URL: <http://www.colm.net/pipermail/ragel-users/attachments/20090902/682311f0/attachment-0001.c>

More information about the ragel-users mailing list