This is the mail archive of the guile@sourceware.cygnus.com mailing list for the Guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: logxxx and bignums


roland.kaufmann@space.at wrote:
> 
>                                 Hello,
> I hope everyone agrees that bit operations should treat negative
> integers (bignums and fixnums) as two's complements (like CL does)
> even if they might be implemented differently?
> 
> [this is from CVS as of June last year, before they installed a
>   firewall here :-( ]
> 
> guile> (map (lambda (pos) (list pos (logbit? pos -1))) (iota 40))
> ((0 #t) (1 #t) (2 #t) (3 #t) (4 #t) (5 #t) (6 #t) (7 #t) (8 #t) (9 #t)
>  (10 #t) (11 #t) (12 #t) (13 #t) (14 #t) (15 #t) (16 #t) (17 #t) (18 #t)
>  (19 #t) (20 #t) (21 #t) (22 #t) (23 #t) (24 #t) (25 #t) (26 #t) (27 #t)
>  (28 #t) (29 #t) (30 #f) (31 #f) (32 #t) (33 #t) (34 #t) (35 #t) (36 #t)
>  (37 #t) (38 #t) (39 #t))


This fails on current cvs guile.  logbit? requires a positive number for
second argument.  Bug or design?

But yes.  Bignums are sign magnitude in storage layout and I agree that
they should behave as 2's complement.


> SCM version 4e6 (yes, I know it's old, but it does handle bignums)
> gets this right:

I just got the latest (5d2) SCM code last night.  Yes, the code for
bignum logxxx routines is there.  There appears to be an fsf copyright
on subr.c.  I think it would be much better to migrate that code into
guile than anything I'd come up with.  And I was hoping to get back into
some real coding again. :(

-Dale

Here is the copyright from subr.c:

/* Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997 Free
Software Foundation, Inc.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2, or (at your option)
 * any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this software; see the file COPYING.  If not, write to
 * the Free Software Foundation, 59 Temple Place, Suite 330, Boston, MA
02111, USA.
 *
 * As a special exception, the Free Software Foundation gives permission
 * for additional uses of the text contained in its release of GUILE.
 *
 * The exception is that, if you link the GUILE library with other files
 * to produce an executable, this does not by itself cause the
 * resulting executable to be covered by the GNU General Public License.
 * Your use of that executable is in no way restricted on account of
 * linking the GUILE library code into it.
 *
 * This exception does not however invalidate any other reasons why
 * the executable file might be covered by the GNU General Public
License.
 *
 * This exception applies only to the code released by the
 * Free Software Foundation under the name GUILE.  If you copy
 * code from other Free Software Foundation releases into a copy of
 * GUILE, as the General Public License permits, the exception does
 * not apply to the code that you add in this way.  To avoid misleading
 * anyone as to the status of such modified files, you must delete
 * this exception notice from them.
 *
 * If you write modifications of your own for GUILE, it is your choice
 * whether to permit this exception to apply to your modifications.
 * If you do not wish that, delete this exception notice.
 */

/* "subr.c" integer and other Scheme procedures
   Author: Aubrey Jaffer */

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]