Catonano <caton...@gmail.com> 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.

       Mark

Reply via email to