[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: unsigned-int

From: Mark H Weaver
Subject: Re: unsigned-int
Date: Thu, 22 Jun 2017 12:20:20 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux)

Catonano <address@hidden> writes:

> I can't extract correct values from unsigned-int's
> I can extract correct values from int, unsigned-short
> but NOT form an unsigned-int
> In that case the number that comes out is plainly wrong
> This is how I extract a number from an int (and it works)
> (bytevector-uint-ref (pointer->bytevector
>           outcome-ptr (sizeof int)) 0
>           (endianness big) 1) )

You need to use 'bytevector-int-ref', not 'bytevector-uint-ref', to
extract a signed integer.

> This is an unsigned-short (and it works)
> (bytevector-uint-ref (pointer->bytevector
>                    columns-ptr (sizeof unsigned-short)) 0
>                    (endianness big) 1)
> This is an unsigned-int and it DOESN'T work
> (bytevector-uint-ref (pointer->bytevector
>                     rows-ptr (sizeof unsigned-int)) 0
>                    (endianness big) 1)

There's also a problem with all three of your examples above.  You're
passing '1' as the final argument to 'bytevector-uint-ref'.  That's the
width in bytes of the numeric field to access.  In all cases, those 1s
should be replaced with (sizeof <type>).

Also, I'm not sure why you're specifying (endianness big) here.  I would
think (native-endianness) would be appropriate here.  Given this, and
the fact that you're passing the wrong width, makes me surprised that
this is working for you at all.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]