unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: Mark H Weaver <mhw@netris.org>
To: Catonano <catonano@gmail.com>
Cc: guile-user@gnu.org
Subject: Re: unsigned-int
Date: Thu, 22 Jun 2017 12:20:20 -0400	[thread overview]
Message-ID: <87efuchu4b.fsf@netris.org> (raw)
In-Reply-To: <CAJ98PDyJDoE6n00G=3Yf1h_-R8oS4XoZQOCzkcHVGcLnbaCp1Q@mail.gmail.com> (catonano@gmail.com's message of "Thu, 22 Jun 2017 11:42:45 +0200")

Catonano <catonano@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



  parent reply	other threads:[~2017-06-22 16:20 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-22  9:42 unsigned-int Catonano
2017-06-22  9:56 ` unsigned-int Catonano
2017-06-22 16:20 ` Mark H Weaver [this message]
2017-06-22 19:13   ` unsigned-int Catonano
2017-06-22 19:33     ` unsigned-int Catonano
2017-06-22 19:55       ` unsigned-int Catonano
2017-06-22 20:01         ` unsigned-int Catonano
2017-06-22 20:53           ` unsigned-int Catonano
2017-06-23 12:37       ` unsigned-int Mark H Weaver
2017-06-23 12:16     ` unsigned-int Mark H Weaver
2017-06-24  9:17       ` unsigned-int Catonano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87efuchu4b.fsf@netris.org \
    --to=mhw@netris.org \
    --cc=catonano@gmail.com \
    --cc=guile-user@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).