[Top][All Lists]

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

Re: unsigned-int

From: Catonano
Subject: Re: unsigned-int
Date: Thu, 22 Jun 2017 21:13:39 +0200

2017-06-22 18:20 GMT+02:00 Mark H Weaver <address@hidden>:

> 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.

I am extracting an unsigned-int here.
(sizeof int) and (sizeof unsigned-int) happen to be te same

> > 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>).

Ah. I had misunderstood the signature of bytevector-*-ref

> Also, I'm not sure why you're specifying (endianness big) here.

I just attempted with (endianness big). It worked, so I assumed it had to
be right

> I would
> think (native-endianness) would be appropriate here.

Ah ! I hadn't noticed (native-endianness) existed !

> Given this, and
> the fact that you're passing the wrong width, makes me surprised that
> this is working for you at all.

Mark, thank you so much for your review. I appreciate that

I apologize if my questions are naive.
I wrote my last scrap of C code in about 2004 and it never was my thing
Also the manual is a great reference but not a great tutorial and I'm not a
great reader, probably.

Still I'd like to use guile-freexl to extract data from a bunch of xls
files and store such data in a Postgresql db.

I believe that this could be useful to other guilers too

Last time I used a Clojure wrap around an Apache Foundation Java library.
But guile-freexl would be free software !

So, yeah, I'm sorry for the fuss

All that said, I applied the fixes that you suggested and I still get
completely wrong number of rows of the spreadsheets and correct number of

Exactly as before your correctons

So maybe this thingie of mine could use some further attention.

Thanks again

reply via email to

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