From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Mark H Weaver Newsgroups: gmane.lisp.guile.user Subject: Re: unsigned-int Date: Thu, 22 Jun 2017 12:20:20 -0400 Message-ID: <87efuchu4b.fsf@netris.org> References: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1498148475 22633 195.159.176.226 (22 Jun 2017 16:21:15 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 22 Jun 2017 16:21:15 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) Cc: guile-user@gnu.org To: Catonano Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Thu Jun 22 18:21:09 2017 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dO4qx-0005Vn-7D for guile-user@m.gmane.org; Thu, 22 Jun 2017 18:21:07 +0200 Original-Received: from localhost ([::1]:59926 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dO4r2-0005ch-Ce for guile-user@m.gmane.org; Thu, 22 Jun 2017 12:21:12 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:44947) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dO4qT-0005cR-I7 for guile-user@gnu.org; Thu, 22 Jun 2017 12:20:38 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dO4qP-0001oH-LA for guile-user@gnu.org; Thu, 22 Jun 2017 12:20:37 -0400 Original-Received: from world.peace.net ([50.252.239.5]:47539) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dO4qP-0001o9-HW for guile-user@gnu.org; Thu, 22 Jun 2017 12:20:33 -0400 Original-Received: from pool-72-93-34-106.bstnma.east.verizon.net ([72.93.34.106] helo=jojen) by world.peace.net with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1dO4hY-0003cK-Jb; Thu, 22 Jun 2017 12:11:24 -0400 In-Reply-To: (catonano@gmail.com's message of "Thu, 22 Jun 2017 11:42:45 +0200") X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 50.252.239.5 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Original-Sender: "guile-user" Xref: news.gmane.org gmane.lisp.guile.user:13864 Archived-At: Catonano 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 ). 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