GNU logs - #40744, boring messages


Message sent to bug-guix@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#40744: guile-2.2.4 (integer-length 0) erroneously returns 0, not 1
Resent-From: Bengt Richter <bokr@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-guix@HIDDEN
Resent-Date: Tue, 21 Apr 2020 13:05:01 +0000
Resent-Message-ID: <handler.40744.B.15874742524181 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: report 40744
X-GNU-PR-Package: guix
X-GNU-PR-Keywords: 
To: 40744 <at> debbugs.gnu.org
X-Debbugs-Original-To: New-Bug <bug-guix@HIDDEN>
Reply-To: Bengt Richter <bokr@HIDDEN>
Received: via spool by submit <at> debbugs.gnu.org id=B.15874742524181
          (code B ref -1); Tue, 21 Apr 2020 13:05:01 +0000
Received: (at submit) by debbugs.gnu.org; 21 Apr 2020 13:04:12 +0000
Received: from localhost ([127.0.0.1]:49147 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1jQsZM-00015I-V9
	for submit <at> debbugs.gnu.org; Tue, 21 Apr 2020 09:04:12 -0400
Received: from lists.gnu.org ([209.51.188.17]:39940)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <bokr@HIDDEN>) id 1jQsZK-000159-Sx
 for submit <at> debbugs.gnu.org; Tue, 21 Apr 2020 09:04:07 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:45208)
 by lists.gnu.org with esmtp (Exim 4.90_1)
 (envelope-from <bokr@HIDDEN>) id 1jQsZJ-0002OE-Vj
 for bug-guix@HIDDEN; Tue, 21 Apr 2020 09:04:06 -0400
X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00,
 HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H3,
 RCVD_IN_MSPIKE_WL,SPF_PASS autolearn=unavailable autolearn_force=no
 version=3.4.2
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1)
 (envelope-from <bokr@HIDDEN>) id 1jQsZI-0003R9-C7
 for bug-guix@HIDDEN; Tue, 21 Apr 2020 09:04:05 -0400
Received: from imta-36.everyone.net ([216.200.145.36]:53194
 helo=imta-38.everyone.net)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <bokr@HIDDEN>) id 1jQsZG-0003OU-BR
 for bug-guix@HIDDEN; Tue, 21 Apr 2020 09:04:03 -0400
Received: from pps.filterd (omta002.sj2.proofpoint.com [127.0.0.1])
 by imta-38.everyone.net (8.16.0.27/8.16.0.27) with SMTP id 03LD1iSZ014245
 for <bug-guix@HIDDEN>; Tue, 21 Apr 2020 06:03:57 -0700
X-Eon-Originating-Account: i-h_PaSXDAFkwuy2p0jCcvm-XTwSApTPRg-Usrpt6ic
X-Eon-Dm: m0116293.ppops.net
Received: by m0116293.mta.everyone.net (EON-AUTHRELAY2 - 53b92cab) id
 m0116293.5e67f91c.3a7648
 for <bug-guix@HIDDEN>; Tue, 21 Apr 2020 06:03:55 -0700
X-Eon-Sig: AQMHrIJenu874HkkZgIAAAAB,9254880fbaed8d152fcefda3999ec14d
X-Eip: J0zbnjcn_FlGWfQZbncy5_Ug_RcAsNVrjTMlIdScGtI
Date: Tue, 21 Apr 2020 15:03:44 +0200
From: Bengt Richter <bokr@HIDDEN>
Message-ID: <20200421130344.GA9369@LionPure>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
User-Agent: Mutt/1.10.1 (2018-07-13)
X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138, 18.0.676
 definitions=2020-04-21_05:2020-04-20,
 2020-04-21 signatures=0
X-Proofpoint-Spam-Details: rule=notspam policy=default score=0
 priorityscore=1501 malwarescore=0
 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1034
 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0
 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-2002250000
 definitions=main-2004210104
Received-SPF: pass client-ip=216.200.145.36; envelope-from=bokr@HIDDEN;
 helo=imta-38.everyone.net
X-detected-operating-system: by eggs.gnu.org: First seen = 2020/04/21 09:03:58
X-ACL-Warn: Detected OS   = Linux 3.x [generic]
X-Received-From: 216.200.145.36
X-Spam-Score: 0.5 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.4 (-)

Hello guix/guile bug-squashers,

The tl;dr is:
    (integer-length 0) should agree with:
    (string-length (number->string 0 2)) =-> 1
        -- and not:   (integer-length 0) =-> 0

The integer length in bits (short for binary digits :)
is the number digits required to write the integer value
in conventional big-endian digit order, signifying coefficients
of successive powers of the radix used.

This applies irrespective of the radix. Thus "11" in decimal is
  "1*10^1 + 1*10^0"
or hex is
  "11*16^0"
or binary is
  "1*2^1 + 1*2^0"

So, the crux of the argument is that it takes one digit to write
either 1 or 0:
--8<---------------cut here---------------start------------->8---
Inputs: 1 (radix 10, decimal value unsigned 1) (output radix 2)
  Number as radix-2 glyph{0..1} string (unsigned)
  "1"
  Number as glyphs representing coefficient values of radix polynomial for number value:
  ("1")
  (1) -- corresponding coefficient values
  Number as polynomial expression:
  "1*2^0"
  (1) -- corresponding term values
  1 -- sum of term values
  The following should be equal to guile's (integer-length 1):
  1 integer-digit (radix 2)
--8<---------------cut here---------------end--------------->8---

--8<---------------cut here---------------start------------->8---
Inputs: 0 (radix 10, decimal value unsigned 0) (output radix 2)
  Number as radix-2 glyph{0..1} string (unsigned)
  "0"
  Number as glyphs representing coefficient values of radix polynomial for number value:
  ("0")
  (0) -- corresponding coefficient values
  Number as polynomial expression:
  "0*2^0"
  (0) -- corresponding term values
  0 -- sum of term values
  The following should be equal to guile's (integer-length 0):
  1 integer-digit (radix 2)
--8<---------------cut here---------------end--------------->8---

BTW, this works for signed numbers as well, if you use a complement
representation making the sign digit 0 for positive and radix-1 for
negative (thus 0 and 1 for radix 2, and e.g. 0 and f for radix 16).

Decimal is just another radix:

Inputs: -11 (radix 10, decimal value minus 11) (output radix 10)
  Number as radix-10 glyph{0..9} string (radix-complement -sign prefix)
  "989" (complement notation)
   ^--(note that 0 and "9" (radix10 -1) are sign digits for 0 and -1 coefficient values in the polynomial)
  Number as glyphs representing coefficient values of radix polynomial for number value:
  ("-1" "8" "9")
  (-1 8 9) -- corresponding coefficient values
  Number as polynomial expression:
  "-1*10^2 + 8*10^1 + 9*10^0"
  (-100 80 9) -- corresponding term values
  -11 -- sum of term values
  Tip: for guile integer-length, enter unsigned value with output radix 2
  3 integer-digits (radix 10)

The extreme for this version is radix 36:

Inputs: -11 (radix 36, decimal value minus 37) (output radix 36)
  Number as radix-36 glyph{0..z} string (radix-complement -sign prefix)
  "zyz" (complement notation)
   ^--(note that 0 and "z" (radix36 -1) are sign digits for 0 and -1 coefficient values in the polynomial)
  Number as glyphs representing coefficient values of radix polynomial for number value:
  ("-1" "y" "z")
  (-1 34 35) -- corresponding coefficient values
  Number as polynomial expression:
  "-1*36^2 + 34*36^1 + 35*36^0"
  (-1296 1224 35) -- corresponding term values
  -37 -- sum of term values
  Tip: for guile integer-length, enter unsigned value with output radix 2
  3 integer-digits (radix 36)

I got a little carried away exploring the complement notation, and wrote
a thing to explain the meanings. Please copy snip to int2poly and chmod 755 it.
Then run once without args for usage help.

I hope it will convince you that guile (integer-length 0) should be 1 ;-)

--8<---------------cut here---------------start------------->8---
#!/usr/bin/env -S guile -e main -s
!#
;; run without arguments for usage, or read below
;; int2poly-0.1.0 -- 2020-04-21 

(use-modules (ice-9 format)
	     (ice-9 regex))

(define self (basename (car (command-line))))
(define verbose #f)

(define (usage)
  (begin
    (let*((selfxxx (basename (car (command-line)))))
      (begin
	(format (current-error-port)
		"Usage:
        ~a  [-v ] | NUMSTR  [out-radix] [inp-radix]
        where *-radix are entered in decimal, and
        out-radix defaults to 2 and inp-radix defaults to 10,
        but may set independently to 2..36 to demo generality.

        -v for verbose output explanations

        NUMSTR will be written in radix digits representing
        polynomial coefficients, which is presented in series terms
        and evaluated back to the original number.

        The NUMSTR character set is the same as for (number->string radix)
        but could be any chosen set of distinct glyphs for values {0..<radix -1>}.

        guile integer-length can be considered a special case of
        coefficient count for radix 2, which is  printed in the last
        line of output as \"N integer-digits (radix N)\n"
		self ))
      (if (= (integer-length 0) 0)
	  (begin
	  (format #t "\nGuile[1] bug:
    (integer-length 0) should agree with:
    (string-length (number->string 0 2)) =-> ~s
        -- and not:   (integer-length 0) =-> ~s
    And it should agree with integer-digits for ~a 1 and ~a 0
    Try ~a 0, and note that it is 1 for any radix 2-36
    and numstr is 10 for ~a radix radix also for any radix ;-)\n\n"
		  (string-length (number->string 0 2))
		  (integer-length 0)
		  self self self self)
	  (display "[1] ----\n")
	  (system "guile -v")
	  (display "----\n ")
	  )))))

(define (main argl)
  (begin
    (set! argl (cdr argl))
    (if (not (pair? argl)) (begin (usage) (exit)))
    (if (string=? "-v" (car argl)) (begin (set! verbose #t) (set! argl (cdr argl))))
    (if (not (pair? argl)) (begin (usage) (exit)))
    (let*((matstr (string-match "[0-9a-z]+" (string-join argl " "))) ;; for <prefix><substring><suffix>
	  (sgnstr (match:prefix matstr))    ;; [<sign>]
	  (absstr (match:substring matstr)) ;;         <inpnum> [<out-radix>] [<in-radix>] 

	  (matst2 (string-match "[0-9]+" (match:suffix matstr))) ;; demo radix (spec in decimal)  [<out-radix>] [<inp-radix>]
          (radix (if matst2 (string->number (match:substring matst2)) 2)) ;; default demo radix is 2

	  (matst3 (if matst2 (string-match "[0-9]+" (match:suffix matst2)) #f)) ;;                                [<inp-radix>]
	  (iradix (if matst3 (string->number (match:substring matst3)) 10)) ;; default input radix 10

	  (absnum (string->number absstr iradix)) ;; abs math value of input
	  (abswid (string-length (number->string absnum radix)))
	  (radixp (integer-expt radix (+ 1 abswid))) ;; 2nd bit above msb of absnum
	  (usenum (if (string=? "-" sgnstr) (- radixp absnum) (+ radixp absnum))) ;; 10abs or 10000-abs
	                                                                          ;;          _1xyx
	                                                                          ;;      or  10000 if abs=0
	  (numstr1 (number->string usenum radix))
	  (numoff (if (string=? "" sgnstr)
		      2
		      (- (string-length numstr1) (+ 1 abswid))))

	  (numstr (substring numstr1 numoff))
	  (coeffs (map match:substring  (list-matches "(.)" numstr)))
	  (coeffs (if (string=? "" sgnstr)
		      coeffs
		      (begin
			(if (char=? (string-ref numstr 0)
				    (string-ref (number->string (- radix 1) radix) 0))
			    (cons "-1" (cdr coeffs))
			    coeffs))))
	  (coeffv (map (lambda (s) (string->number s radix)) coeffs))
	  (ncoeff (length coeffs))
	  (terms (string-join (reverse (map (lambda (coeff power)
				 (begin (format #f "~d*~d^~d" coeff radix power))) (reverse coeffv) (iota ncoeff))) " + "))
	  (termv (reverse (map (lambda (coeff power)
				 (begin (* coeff (integer-expt radix power)))) (reverse coeffv) (iota ncoeff))))
	  (polyv (apply + termv))

	  (signword (begin (cond
			    ((string=? "" sgnstr) "unsigned")
			    ((string=? "+" sgnstr) "plus")
			    ((string=? "-" sgnstr) "minus")
			    (else (throw 'int2poly "bad sign:" sgnstr)))))
	  (sgnnote (begin (cond
			    ((string=? "" sgnstr) "(unsigned)")
			    ((string=? "+" sgnstr) "(radix-complement +sign prefix)")
			    ((string=? "-" sgnstr) "(radix-complement -sign prefix)")
			    (else (throw 'int2poly "bad sign:" sgnstr)))))
	  )
      (begin
	(format #t "Inputs: ~a~a (radix ~s, decimal value ~a ~s) (output radix ~s)\n" sgnstr absstr iradix signword absnum radix)
        (if verbose (format #t "  Number as radix-~s glyph{~a..~a} string ~a\n"
	 		    radix  (number->string 0 radix) (number->string (- radix 1) radix)  sgnnote))
	(format #t "  ~s~a\n" numstr (if (string=? "" sgnstr) "" " (complement notation)"))
	(if (and verbose (not (string=? sgnstr "")))
	    (format #t "   ^--(note that 0 and ~s (radix~a -1) are sign digits for 0 and -1 coefficient values in the polynomial)\n"
							     (number->string (- radix 1) radix) radix))
	(format #t "~a  ~s\n" (if verbose "  Number as glyphs representing coefficient values of radix polynomial for number value:\n" "") coeffs)
	(format #t "  ~s~a\n" coeffv (if verbose  " -- corresponding coefficient values" ""))
	(format #t "~a  ~s\n" (if verbose "  Number as polynomial expression:\n" "") terms)
	(format #t "  ~s~a\n" termv (if verbose " -- corresponding term values" ""))
	(format #t "  ~s~a\n" polyv (if verbose " -- sum of term values" ""))
	(if verbose
	    (if (and (= radix 2) (string=? sgnstr ""))
		(format #t "  The following should be equal to guile's (integer-length ~s):\n" absnum)
		(format #t "  Tip: for guile integer-length, enter unsigned value with output radix 2\n")))
	(format #t "  ~s integer-digit~a (radix ~a)\n" ncoeff (if (> ncoeff 1) "s" "") radix))
      )))
--8<---------------cut here---------------end--------------->8---

-- 
Regards,
Bengt Richter




Message sent:


Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
X-Mailer: MIME-tools 5.505 (Entity 5.505)
Content-Type: text/plain; charset=utf-8
X-Loop: help-debbugs@HIDDEN
From: help-debbugs@HIDDEN (GNU bug Tracking System)
To: Bengt Richter <bokr@HIDDEN>
Subject: bug#40744: Acknowledgement (guile-2.2.4 (integer-length 0)
 erroneously returns 0, not 1)
Message-ID: <handler.40744.B.15874742524181.ack <at> debbugs.gnu.org>
References: <20200421130344.GA9369@LionPure>
X-Gnu-PR-Message: ack 40744
X-Gnu-PR-Package: guix
Reply-To: 40744 <at> debbugs.gnu.org
Date: Tue, 21 Apr 2020 13:05:02 +0000

Thank you for filing a new bug report with debbugs.gnu.org.

This is an automatically generated reply to let you know your message
has been received.

Your message is being forwarded to the package maintainers and other
interested parties for their attention; they will reply in due course.

Your message has been sent to the package maintainer(s):
 bug-guix@HIDDEN

If you wish to submit further information on this problem, please
send it to 40744 <at> debbugs.gnu.org.

Please do not send mail to help-debbugs@HIDDEN unless you wish
to report a problem with the Bug-tracking system.

--=20
40744: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D40744
GNU Bug Tracking System
Contact help-debbugs@HIDDEN with problems


Message sent to bug-guix@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#40744: guile-2.2.4 (integer-length 0) erroneously returns 0,  not 1
Resent-From: Bengt Richter <bokr@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-guix@HIDDEN
Resent-Date: Sat, 25 Apr 2020 21:35:01 +0000
Resent-Message-ID: <handler.40744.B40744.158785044530746 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 40744
X-GNU-PR-Package: guix
X-GNU-PR-Keywords: 
To: 40744 <at> debbugs.gnu.org
Reply-To: Bengt Richter <bokr@HIDDEN>
Received: via spool by 40744-submit <at> debbugs.gnu.org id=B40744.158785044530746
          (code B ref 40744); Sat, 25 Apr 2020 21:35:01 +0000
Received: (at 40744) by debbugs.gnu.org; 25 Apr 2020 21:34:05 +0000
Received: from localhost ([127.0.0.1]:60516 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1jSSR3-0007zq-1Q
	for submit <at> debbugs.gnu.org; Sat, 25 Apr 2020 17:34:05 -0400
Received: from imta-37.everyone.net ([216.200.145.37]:43396
 helo=imta-38.everyone.net)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <bokr@HIDDEN>) id 1jSSR1-0007zh-Dc
 for 40744 <at> debbugs.gnu.org; Sat, 25 Apr 2020 17:34:03 -0400
Received: from pps.filterd (localhost.localdomain [127.0.0.1])
 by imta-38.everyone.net (8.16.0.27/8.16.0.27) with SMTP id 03PLTxLE007856
 for <40744 <at> debbugs.gnu.org>; Sat, 25 Apr 2020 14:34:02 -0700
X-Eon-Originating-Account: ACsXzf8YmkZXa07vJAvbk2qxij-IGbzGj9chJ3UfMT4
X-Eon-Dm: m0116787.ppops.net
Received: by m0116787.mta.everyone.net (EON-AUTHRELAY2 - 5a81c6e6) id
 m0116787.5e67f91f.58a24e
 for <40744 <at> debbugs.gnu.org>; Sat, 25 Apr 2020 14:34:00 -0700
X-Eon-Sig: AQMHrIJepKzIQZ2k+wIAAAAB,c49e61b7f61d6e045cd5a99d1839b584
X-Eip: gR80SeKLTRv3UtxEvsWmn9NulnVOMSBQ6_NP_J0R0gk
Date: Sat, 25 Apr 2020 23:33:50 +0200
From: Bengt Richter <bokr@HIDDEN>
Message-ID: <20200425213350.GA10462@LionPure>
References: <20200421130344.GA9369@LionPure>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
In-Reply-To: <20200421130344.GA9369@LionPure>
User-Agent: Mutt/1.10.1 (2018-07-13)
X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138, 18.0.676
 definitions=2020-04-25_13:2020-04-24,
 2020-04-25 signatures=0
X-Proofpoint-Spam-Details: rule=notspam policy=default score=0
 priorityscore=1501 malwarescore=0
 suspectscore=13 phishscore=0 bulkscore=0 spamscore=0 clxscore=1034
 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=775 adultscore=0
 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-2002250000
 definitions=main-2004250188
X-Spam-Score: -0.5 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.4 (-)

Apologies for my faux pas ;-/

This was not a guix bug, and you have rightly ignored my report.
(now submitted to bug-guile, with hopes of nz human acks :)

(I guess it will get a new number, so 40744 can be closed?)

(BTW, no offense intended in addressing you as "guix/guile bug-squashers" ;-/)
On +2020-04-21 15:03:44 +0200, Bengt Richter wrote:
> Hello guix/guile bug-squashers,
> 
> The tl;dr is:
>     (integer-length 0) should agree with:
>     (string-length (number->string 0 2)) =-> 1
>         -- and not:   (integer-length 0) =-> 0
-- 
Regards,
Bengt Richter




Message received at control <at> debbugs.gnu.org:


Received: (at control) by debbugs.gnu.org; 25 Apr 2020 23:28:11 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Apr 25 19:28:10 2020
Received: from localhost ([127.0.0.1]:60550 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1jSUDS-0002UR-N4
	for submit <at> debbugs.gnu.org; Sat, 25 Apr 2020 19:28:10 -0400
Received: from wout4-smtp.messagingengine.com ([64.147.123.20]:41229)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <leo@HIDDEN>) id 1jSUDD-0002Td-B3
 for control <at> debbugs.gnu.org; Sat, 25 Apr 2020 19:28:08 -0400
Received: from compute2.internal (compute2.nyi.internal [10.202.2.42])
 by mailout.west.internal (Postfix) with ESMTP id 223F31933;
 Sat, 25 Apr 2020 19:27:49 -0400 (EDT)
Received: from mailfrontend1 ([10.202.2.162])
 by compute2.internal (MEProxy); Sat, 25 Apr 2020 19:27:49 -0400
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=famulari.name;
 h=date:from:to:message-id:mime-version:content-type; s=mesmtp;
 bh=0VZRQU+AlsvUP02bjhVZCBvJHH5Wt/CgDAaVE+zTKWc=; b=t0BSzxz//HC4
 Jh9M5IhoiFGRAE4chAiVG9+C1/sprWArZZCQaYn+E/k8iOEzz5xPNXlOW0qDordT
 TFHQHGRrcQqToqpXhuDGnhfodQ+nu6JZXMlYYv7oZmiWYPO24QASpUs6o/TkOhVk
 aq/mBAOA7kGCBdRywkJpB5yvbd6TzkA=
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=
 messagingengine.com; h=content-type:date:from:message-id
 :mime-version:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender
 :x-sasl-enc; s=fm2; bh=0VZRQU+AlsvUP02bjhVZCBvJHH5Wt/CgDAaVE+zTK
 Wc=; b=jybnqBgesXUoDbmSYuNvEa5QBfxQrbSMidghQhdUHTS/bJqXdC7NwYOyM
 0n/0713UNkhgW+gsZjx4pOLM+u2QRe6wrrt0X1S8jlG7TXeutUd9UJkVuLXV7ByC
 Itp3VuJSnEbr4yHEi+csg64+uZwXsr46ifi1tmI9aXcVs/hffI/zgO4t+mu7+vfj
 MV6lxvTf0YBF9wQvdUqGi5dwuPVmMVizd8wgFyk9NwPKZqqJZBqwZYnfOavFohPB
 8t6pLsjFGRTI7/MO4NOynz++6GisTTq15vzfoUHTvpN47NQx5uTId2g3GbZNcRVk
 gUgKDRZqU/NDJuiXdXNjDI7zfzF9Q==
X-ME-Sender: <xms:dMekXqzAPMh__rcTl6e74W8FWL95XojVBfg5jhPUaaQQZiNp_3uwiQ>
X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduhedrheehgddvudcutefuodetggdotefrodftvf
 curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu
 uegrihhlohhuthemuceftddtnecugfhmphhthicushhusghjvggtthculddutddmnecujf
 gurhepfffhvffkgggtugesthdtredttddtvdenucfhrhhomhepnfgvohcuhfgrmhhulhgr
 rhhiuceolhgvohesfhgrmhhulhgrrhhirdhnrghmvgeqnecukfhppeejiedruddvgedrud
 efkedrieefnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhho
 mheplhgvohesfhgrmhhulhgrrhhirdhnrghmvg
X-ME-Proxy: <xmx:dMekXgw5REiAVEp38roBhEH7OXCdAFoAlGb0SEig0sLzGSdCEpXUWQ>
 <xmx:dMekXpSvglVCqQgAn0xDg2n14mt86czdOo0dGZhhMWm4JTbUXrvUww>
 <xmx:dMekXjOBQCKx0WLg08hqiqvP3IC3lSqYsAa5H58yBBbHt_3hzo7v5A>
 <xmx:dMekXkOjAHRDMhi9qk3fhTr6D1RsDRioSHLtNtLX5mt91LCzmjd7lQ>
Received: from localhost (c-76-124-138-63.hsd1.pa.comcast.net [76.124.138.63])
 by mail.messagingengine.com (Postfix) with ESMTPA id 601E53280066
 for <control <at> debbugs.gnu.org>; Sat, 25 Apr 2020 19:27:48 -0400 (EDT)
Date: Sat, 25 Apr 2020 19:27:46 -0400
From: Leo Famulari <leo@HIDDEN>
To: control <at> debbugs.gnu.org
Message-ID: <20200425232746.GA2829@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
X-Spam-Score: 2.0 (++)
X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org",
 has NOT identified this incoming email as spam.  The original
 message has been attached to this so you can view it or label
 similar future email.  If you have any questions, see
 the administrator of that system for details.
 Content preview:  reassign 40744 guile 
 Content analysis details:   (2.0 points, 10.0 required)
 pts rule name              description
 ---- ---------------------- --------------------------------------------------
 0.0 URIBL_BLOCKED          ADMINISTRATOR NOTICE: The query to URIBL was
 blocked.  See
 http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block
 for more information. [URIs: famulari.name]
 -0.0 SPF_HELO_PASS          SPF: HELO matches SPF record
 0.0 T_SPF_TEMPERROR        SPF: test of record failed (temperror)
 1.8 MISSING_SUBJECT        Missing Subject: header
 0.2 NO_SUBJECT             Extra score for no subject
X-Debbugs-Envelope-To: control
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: 0.3 (/)

reassign 40744 guile




Message received at control <at> debbugs.gnu.org:


Received: (at control) by debbugs.gnu.org; 25 Apr 2020 23:28:17 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Apr 25 19:28:17 2020
Received: from localhost ([127.0.0.1]:60552 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1jSUDY-0002Uf-Ut
	for submit <at> debbugs.gnu.org; Sat, 25 Apr 2020 19:28:17 -0400
Received: from wout4-smtp.messagingengine.com ([64.147.123.20]:33261)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <leo@HIDDEN>) id 1jSUDR-0002UA-Ij
 for control <at> debbugs.gnu.org; Sat, 25 Apr 2020 19:28:09 -0400
Received: from compute2.internal (compute2.nyi.internal [10.202.2.42])
 by mailout.west.internal (Postfix) with ESMTP id 0147D1990;
 Sat, 25 Apr 2020 19:28:03 -0400 (EDT)
Received: from mailfrontend1 ([10.202.2.162])
 by compute2.internal (MEProxy); Sat, 25 Apr 2020 19:28:04 -0400
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=famulari.name;
 h=date:from:to:message-id:mime-version:content-type; s=mesmtp;
 bh=5qxWaFsJyu8eyWny7fEgJ+z1PzLZ0w/NCFGyDz1lCSk=; b=tSZQ0aFjP0nY
 B3geHw12MJsAGPedexb3yXoFcQ8yIsn4OjI8/x11Scuy4HxXCTobxIkHMsiETZ9b
 7NDagPE5/31g4NDkRIRxWJVSX25IQpVa33kCq2mIKuCwaEYi/FlU+S5MBkQdsrup
 TGws7z7Ity9dGXFDcnW78AtWwB+Wr0I=
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=
 messagingengine.com; h=content-type:date:from:message-id
 :mime-version:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender
 :x-sasl-enc; s=fm2; bh=5qxWaFsJyu8eyWny7fEgJ+z1PzLZ0w/NCFGyDz1lC
 Sk=; b=sOhri/J+T+QZ+Yk9Ck/5sS0Jx9KAANAGXR7MEeCtagUVJG9EpK6hOrsYW
 aZIId+urvuvh/k/rYarM1UaxSX+0dkDKw4aNmAhqAy9xtc5Do4RR2/dt396OjP6N
 mSnT1CjhKer+JyrCON3LiSYcjTtDzyqa3WVRWFdWYZr53Nri+nc4R1LyYJYYOdfj
 Rdrzk+6fupE8mwHYsam1QSkSymX3j0LEMvKj4IHmD/jXcA63qDEThxiumpOAdTue
 Q8+mzEn3obSL2S6AkQ08AWqA4PzgAu41iMLHpXm9ohd7VbfqNUlKxFdulWd8AgvF
 P0EwE/QWMX3DwiIT1wT18EpK7+PWQ==
X-ME-Sender: <xms:g8ekXsSHZW2TqyZ6jNd5SbnBg4oXTkHG2_zV1ehB2KoRGC9HCHuTkg>
X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduhedrheehgddvudcutefuodetggdotefrodftvf
 curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu
 uegrihhlohhuthemuceftddtnecugfhmphhthicushhusghjvggtthculddutddmnecujf
 gurhepfffhvffkgggtugesthdtredttddtvdenucfhrhhomhepnfgvohcuhfgrmhhulhgr
 rhhiuceolhgvohesfhgrmhhulhgrrhhirdhnrghmvgeqnecukfhppeejiedruddvgedrud
 efkedrieefnecuvehluhhsthgvrhfuihiivgepudenucfrrghrrghmpehmrghilhhfrhho
 mheplhgvohesfhgrmhhulhgrrhhirdhnrghmvg
X-ME-Proxy: <xmx:g8ekXt0pmUU2CZImRXf46FOXkRe53jMaIGSnqRGQJ8p5_nRney5tmw>
 <xmx:g8ekXq9G2PEAU8SVb1NzTuKBhpQIqPkpFGm-dRiMx12skT-4D2vZvQ>
 <xmx:g8ekXpaw01SVETQhode3MO9SC6OviKWZXd5FlspjtOTO_Vv55HmWtQ>
 <xmx:g8ekXtrUupsC6lj5h4XIqWs3WOlegOtozYIzl-I3C7N8iM54TZq5qw>
Received: from localhost (c-76-124-138-63.hsd1.pa.comcast.net [76.124.138.63])
 by mail.messagingengine.com (Postfix) with ESMTPA id 5B19B328005A
 for <control <at> debbugs.gnu.org>; Sat, 25 Apr 2020 19:28:03 -0400 (EDT)
Date: Sat, 25 Apr 2020 19:28:01 -0400
From: Leo Famulari <leo@HIDDEN>
To: control <at> debbugs.gnu.org
Message-ID: <20200425232801.GB2829@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
X-Spam-Score: 1.3 (+)
X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org",
 has NOT identified this incoming email as spam.  The original
 message has been attached to this so you can view it or label
 similar future email.  If you have any questions, see
 the administrator of that system for details.
 Content preview:  merge 40744 40855 
 Content analysis details:   (1.3 points, 10.0 required)
 pts rule name              description
 ---- ---------------------- --------------------------------------------------
 0.0 URIBL_BLOCKED          ADMINISTRATOR NOTICE: The query to URIBL was
 blocked.  See
 http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block
 for more information. [URIs: famulari.name]
 -0.0 SPF_PASS               SPF: sender matches SPF record
 -0.0 SPF_HELO_PASS          SPF: HELO matches SPF record
 -0.7 RCVD_IN_DNSWL_LOW      RBL: Sender listed at https://www.dnswl.org/,
 low trust [64.147.123.20 listed in list.dnswl.org]
 1.8 MISSING_SUBJECT        Missing Subject: header
 0.2 NO_SUBJECT             Extra score for no subject
X-Debbugs-Envelope-To: control
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: 0.3 (/)

merge 40744 40855




Message sent:


MIME-Version: 1.0
X-Mailer: MIME-tools 5.505 (Entity 5.505)
X-Loop: help-debbugs@HIDDEN
From: help-debbugs@HIDDEN (GNU bug Tracking System)
To: =?UTF-8?Q?Bj=C3=B6rn_?= =?UTF-8?Q?H=C3=B6fling?=
 <bjoern.hoefling@HIDDEN>
Subject: bug#40744: closed (guile-2.2.4 (integer-length 0) erroneously
 returns 0, not 1)
CC: tracker <at> debbugs.gnu.org
Message-ID: <handler.40744.D40744.158809730915229.ackdone <at> debbugs.gnu.org>
References: <20200428200810.7d619d27@alma-ubu>
 <20200421130344.GA9369@LionPure>
X-Gnu-PR-Message: closed 40744
X-Gnu-PR-Package: guile
Date: Tue, 28 Apr 2020 18:09:02 +0000
Content-Type: multipart/mixed; boundary="----------=_1588097342-15286-0"

This is a multi-part message in MIME format...

------------=_1588097342-15286-0
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=utf-8

Your message dated Tue, 28 Apr 2020 20:08:10 +0200
with message-id <20200428200810.7d619d27@alma-ubu>
and subject line Re: bug#40744: guile-2.2.4 (integer-length 0) erroneously =
returns 0, not 1
has caused the debbugs.gnu.org bug report #40744,
regarding guile-2.2.4 (integer-length 0) erroneously returns 0, not 1
to be marked as done.

(If you believe you have received this mail in error, please contact
help-debbugs@HIDDEN)


--=20
40744: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D40744
GNU Bug Tracking System
Contact help-debbugs@HIDDEN with problems

------------=_1588097342-15286-0
Content-Type: message/rfc822
Content-Disposition: inline
Content-Transfer-Encoding: 7bit

Received: (at submit) by debbugs.gnu.org; 21 Apr 2020 13:04:12 +0000
Received: from localhost ([127.0.0.1]:49147 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1jQsZM-00015I-V9
	for submit <at> debbugs.gnu.org; Tue, 21 Apr 2020 09:04:12 -0400
Received: from lists.gnu.org ([209.51.188.17]:39940)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <bokr@HIDDEN>) id 1jQsZK-000159-Sx
 for submit <at> debbugs.gnu.org; Tue, 21 Apr 2020 09:04:07 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:45208)
 by lists.gnu.org with esmtp (Exim 4.90_1)
 (envelope-from <bokr@HIDDEN>) id 1jQsZJ-0002OE-Vj
 for bug-guix@HIDDEN; Tue, 21 Apr 2020 09:04:06 -0400
X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00,
 HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H3,
 RCVD_IN_MSPIKE_WL,SPF_PASS autolearn=unavailable autolearn_force=no
 version=3.4.2
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1)
 (envelope-from <bokr@HIDDEN>) id 1jQsZI-0003R9-C7
 for bug-guix@HIDDEN; Tue, 21 Apr 2020 09:04:05 -0400
Received: from imta-36.everyone.net ([216.200.145.36]:53194
 helo=imta-38.everyone.net)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <bokr@HIDDEN>) id 1jQsZG-0003OU-BR
 for bug-guix@HIDDEN; Tue, 21 Apr 2020 09:04:03 -0400
Received: from pps.filterd (omta002.sj2.proofpoint.com [127.0.0.1])
 by imta-38.everyone.net (8.16.0.27/8.16.0.27) with SMTP id 03LD1iSZ014245
 for <bug-guix@HIDDEN>; Tue, 21 Apr 2020 06:03:57 -0700
X-Eon-Originating-Account: i-h_PaSXDAFkwuy2p0jCcvm-XTwSApTPRg-Usrpt6ic
X-Eon-Dm: m0116293.ppops.net
Received: by m0116293.mta.everyone.net (EON-AUTHRELAY2 - 53b92cab) id
 m0116293.5e67f91c.3a7648
 for <bug-guix@HIDDEN>; Tue, 21 Apr 2020 06:03:55 -0700
X-Eon-Sig: AQMHrIJenu874HkkZgIAAAAB,9254880fbaed8d152fcefda3999ec14d
X-Eip: J0zbnjcn_FlGWfQZbncy5_Ug_RcAsNVrjTMlIdScGtI
Date: Tue, 21 Apr 2020 15:03:44 +0200
From: Bengt Richter <bokr@HIDDEN>
To: New-Bug <bug-guix@HIDDEN>
Subject: guile-2.2.4 (integer-length 0) erroneously returns 0, not 1
Message-ID: <20200421130344.GA9369@LionPure>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
User-Agent: Mutt/1.10.1 (2018-07-13)
X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138, 18.0.676
 definitions=2020-04-21_05:2020-04-20,
 2020-04-21 signatures=0
X-Proofpoint-Spam-Details: rule=notspam policy=default score=0
 priorityscore=1501 malwarescore=0
 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1034
 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0
 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-2002250000
 definitions=main-2004210104
Received-SPF: pass client-ip=216.200.145.36; envelope-from=bokr@HIDDEN;
 helo=imta-38.everyone.net
X-detected-operating-system: by eggs.gnu.org: First seen = 2020/04/21 09:03:58
X-ACL-Warn: Detected OS   = Linux 3.x [generic]
X-Received-From: 216.200.145.36
X-Spam-Score: 0.5 (/)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Reply-To: Bengt Richter <bokr@HIDDEN>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.4 (-)

Hello guix/guile bug-squashers,

The tl;dr is:
    (integer-length 0) should agree with:
    (string-length (number->string 0 2)) =-> 1
        -- and not:   (integer-length 0) =-> 0

The integer length in bits (short for binary digits :)
is the number digits required to write the integer value
in conventional big-endian digit order, signifying coefficients
of successive powers of the radix used.

This applies irrespective of the radix. Thus "11" in decimal is
  "1*10^1 + 1*10^0"
or hex is
  "11*16^0"
or binary is
  "1*2^1 + 1*2^0"

So, the crux of the argument is that it takes one digit to write
either 1 or 0:
--8<---------------cut here---------------start------------->8---
Inputs: 1 (radix 10, decimal value unsigned 1) (output radix 2)
  Number as radix-2 glyph{0..1} string (unsigned)
  "1"
  Number as glyphs representing coefficient values of radix polynomial for number value:
  ("1")
  (1) -- corresponding coefficient values
  Number as polynomial expression:
  "1*2^0"
  (1) -- corresponding term values
  1 -- sum of term values
  The following should be equal to guile's (integer-length 1):
  1 integer-digit (radix 2)
--8<---------------cut here---------------end--------------->8---

--8<---------------cut here---------------start------------->8---
Inputs: 0 (radix 10, decimal value unsigned 0) (output radix 2)
  Number as radix-2 glyph{0..1} string (unsigned)
  "0"
  Number as glyphs representing coefficient values of radix polynomial for number value:
  ("0")
  (0) -- corresponding coefficient values
  Number as polynomial expression:
  "0*2^0"
  (0) -- corresponding term values
  0 -- sum of term values
  The following should be equal to guile's (integer-length 0):
  1 integer-digit (radix 2)
--8<---------------cut here---------------end--------------->8---

BTW, this works for signed numbers as well, if you use a complement
representation making the sign digit 0 for positive and radix-1 for
negative (thus 0 and 1 for radix 2, and e.g. 0 and f for radix 16).

Decimal is just another radix:

Inputs: -11 (radix 10, decimal value minus 11) (output radix 10)
  Number as radix-10 glyph{0..9} string (radix-complement -sign prefix)
  "989" (complement notation)
   ^--(note that 0 and "9" (radix10 -1) are sign digits for 0 and -1 coefficient values in the polynomial)
  Number as glyphs representing coefficient values of radix polynomial for number value:
  ("-1" "8" "9")
  (-1 8 9) -- corresponding coefficient values
  Number as polynomial expression:
  "-1*10^2 + 8*10^1 + 9*10^0"
  (-100 80 9) -- corresponding term values
  -11 -- sum of term values
  Tip: for guile integer-length, enter unsigned value with output radix 2
  3 integer-digits (radix 10)

The extreme for this version is radix 36:

Inputs: -11 (radix 36, decimal value minus 37) (output radix 36)
  Number as radix-36 glyph{0..z} string (radix-complement -sign prefix)
  "zyz" (complement notation)
   ^--(note that 0 and "z" (radix36 -1) are sign digits for 0 and -1 coefficient values in the polynomial)
  Number as glyphs representing coefficient values of radix polynomial for number value:
  ("-1" "y" "z")
  (-1 34 35) -- corresponding coefficient values
  Number as polynomial expression:
  "-1*36^2 + 34*36^1 + 35*36^0"
  (-1296 1224 35) -- corresponding term values
  -37 -- sum of term values
  Tip: for guile integer-length, enter unsigned value with output radix 2
  3 integer-digits (radix 36)

I got a little carried away exploring the complement notation, and wrote
a thing to explain the meanings. Please copy snip to int2poly and chmod 755 it.
Then run once without args for usage help.

I hope it will convince you that guile (integer-length 0) should be 1 ;-)

--8<---------------cut here---------------start------------->8---
#!/usr/bin/env -S guile -e main -s
!#
;; run without arguments for usage, or read below
;; int2poly-0.1.0 -- 2020-04-21 

(use-modules (ice-9 format)
	     (ice-9 regex))

(define self (basename (car (command-line))))
(define verbose #f)

(define (usage)
  (begin
    (let*((selfxxx (basename (car (command-line)))))
      (begin
	(format (current-error-port)
		"Usage:
        ~a  [-v ] | NUMSTR  [out-radix] [inp-radix]
        where *-radix are entered in decimal, and
        out-radix defaults to 2 and inp-radix defaults to 10,
        but may set independently to 2..36 to demo generality.

        -v for verbose output explanations

        NUMSTR will be written in radix digits representing
        polynomial coefficients, which is presented in series terms
        and evaluated back to the original number.

        The NUMSTR character set is the same as for (number->string radix)
        but could be any chosen set of distinct glyphs for values {0..<radix -1>}.

        guile integer-length can be considered a special case of
        coefficient count for radix 2, which is  printed in the last
        line of output as \"N integer-digits (radix N)\n"
		self ))
      (if (= (integer-length 0) 0)
	  (begin
	  (format #t "\nGuile[1] bug:
    (integer-length 0) should agree with:
    (string-length (number->string 0 2)) =-> ~s
        -- and not:   (integer-length 0) =-> ~s
    And it should agree with integer-digits for ~a 1 and ~a 0
    Try ~a 0, and note that it is 1 for any radix 2-36
    and numstr is 10 for ~a radix radix also for any radix ;-)\n\n"
		  (string-length (number->string 0 2))
		  (integer-length 0)
		  self self self self)
	  (display "[1] ----\n")
	  (system "guile -v")
	  (display "----\n ")
	  )))))

(define (main argl)
  (begin
    (set! argl (cdr argl))
    (if (not (pair? argl)) (begin (usage) (exit)))
    (if (string=? "-v" (car argl)) (begin (set! verbose #t) (set! argl (cdr argl))))
    (if (not (pair? argl)) (begin (usage) (exit)))
    (let*((matstr (string-match "[0-9a-z]+" (string-join argl " "))) ;; for <prefix><substring><suffix>
	  (sgnstr (match:prefix matstr))    ;; [<sign>]
	  (absstr (match:substring matstr)) ;;         <inpnum> [<out-radix>] [<in-radix>] 

	  (matst2 (string-match "[0-9]+" (match:suffix matstr))) ;; demo radix (spec in decimal)  [<out-radix>] [<inp-radix>]
          (radix (if matst2 (string->number (match:substring matst2)) 2)) ;; default demo radix is 2

	  (matst3 (if matst2 (string-match "[0-9]+" (match:suffix matst2)) #f)) ;;                                [<inp-radix>]
	  (iradix (if matst3 (string->number (match:substring matst3)) 10)) ;; default input radix 10

	  (absnum (string->number absstr iradix)) ;; abs math value of input
	  (abswid (string-length (number->string absnum radix)))
	  (radixp (integer-expt radix (+ 1 abswid))) ;; 2nd bit above msb of absnum
	  (usenum (if (string=? "-" sgnstr) (- radixp absnum) (+ radixp absnum))) ;; 10abs or 10000-abs
	                                                                          ;;          _1xyx
	                                                                          ;;      or  10000 if abs=0
	  (numstr1 (number->string usenum radix))
	  (numoff (if (string=? "" sgnstr)
		      2
		      (- (string-length numstr1) (+ 1 abswid))))

	  (numstr (substring numstr1 numoff))
	  (coeffs (map match:substring  (list-matches "(.)" numstr)))
	  (coeffs (if (string=? "" sgnstr)
		      coeffs
		      (begin
			(if (char=? (string-ref numstr 0)
				    (string-ref (number->string (- radix 1) radix) 0))
			    (cons "-1" (cdr coeffs))
			    coeffs))))
	  (coeffv (map (lambda (s) (string->number s radix)) coeffs))
	  (ncoeff (length coeffs))
	  (terms (string-join (reverse (map (lambda (coeff power)
				 (begin (format #f "~d*~d^~d" coeff radix power))) (reverse coeffv) (iota ncoeff))) " + "))
	  (termv (reverse (map (lambda (coeff power)
				 (begin (* coeff (integer-expt radix power)))) (reverse coeffv) (iota ncoeff))))
	  (polyv (apply + termv))

	  (signword (begin (cond
			    ((string=? "" sgnstr) "unsigned")
			    ((string=? "+" sgnstr) "plus")
			    ((string=? "-" sgnstr) "minus")
			    (else (throw 'int2poly "bad sign:" sgnstr)))))
	  (sgnnote (begin (cond
			    ((string=? "" sgnstr) "(unsigned)")
			    ((string=? "+" sgnstr) "(radix-complement +sign prefix)")
			    ((string=? "-" sgnstr) "(radix-complement -sign prefix)")
			    (else (throw 'int2poly "bad sign:" sgnstr)))))
	  )
      (begin
	(format #t "Inputs: ~a~a (radix ~s, decimal value ~a ~s) (output radix ~s)\n" sgnstr absstr iradix signword absnum radix)
        (if verbose (format #t "  Number as radix-~s glyph{~a..~a} string ~a\n"
	 		    radix  (number->string 0 radix) (number->string (- radix 1) radix)  sgnnote))
	(format #t "  ~s~a\n" numstr (if (string=? "" sgnstr) "" " (complement notation)"))
	(if (and verbose (not (string=? sgnstr "")))
	    (format #t "   ^--(note that 0 and ~s (radix~a -1) are sign digits for 0 and -1 coefficient values in the polynomial)\n"
							     (number->string (- radix 1) radix) radix))
	(format #t "~a  ~s\n" (if verbose "  Number as glyphs representing coefficient values of radix polynomial for number value:\n" "") coeffs)
	(format #t "  ~s~a\n" coeffv (if verbose  " -- corresponding coefficient values" ""))
	(format #t "~a  ~s\n" (if verbose "  Number as polynomial expression:\n" "") terms)
	(format #t "  ~s~a\n" termv (if verbose " -- corresponding term values" ""))
	(format #t "  ~s~a\n" polyv (if verbose " -- sum of term values" ""))
	(if verbose
	    (if (and (= radix 2) (string=? sgnstr ""))
		(format #t "  The following should be equal to guile's (integer-length ~s):\n" absnum)
		(format #t "  Tip: for guile integer-length, enter unsigned value with output radix 2\n")))
	(format #t "  ~s integer-digit~a (radix ~a)\n" ncoeff (if (> ncoeff 1) "s" "") radix))
      )))
--8<---------------cut here---------------end--------------->8---

-- 
Regards,
Bengt Richter



------------=_1588097342-15286-0
Content-Type: message/rfc822
Content-Disposition: inline
Content-Transfer-Encoding: 7bit

Received: (at 40744-done) by debbugs.gnu.org; 28 Apr 2020 18:08:29 +0000
Received: from localhost ([127.0.0.1]:41424 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1jTUei-0003xZ-BD
	for submit <at> debbugs.gnu.org; Tue, 28 Apr 2020 14:08:28 -0400
Received: from m4s11.vlinux.de ([83.151.27.109]:59022 helo=bjoernhoefling.de)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <bjoern.hoefling@HIDDEN>)
 id 1jTUeS-0003wp-RP
 for 40744-done <at> debbugs.gnu.org; Tue, 28 Apr 2020 14:08:25 -0400
Received: from alma-ubu (p508ACA3F.dip0.t-ipconnect.de [80.138.202.63])
 (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
 (No client certificate requested)
 by bjoernhoefling.de (Postfix) with ESMTPSA id 747483F861;
 Tue, 28 Apr 2020 20:08:11 +0200 (CEST)
Date: Tue, 28 Apr 2020 20:08:10 +0200
From: =?UTF-8?B?QmrDtnJuIEjDtmZsaW5n?= <bjoern.hoefling@HIDDEN>
To: Bengt Richter <bokr@HIDDEN>
Subject: Re: bug#40744: guile-2.2.4 (integer-length 0) erroneously returns
 0, not 1
Message-ID: <20200428200810.7d619d27@alma-ubu>
In-Reply-To: <20200425213350.GA10462@LionPure>
References: <20200421130344.GA9369@LionPure> <20200425213350.GA10462@LionPure>
X-Mailer: Claws Mail 3.16.0 (GTK+ 2.24.32; x86_64-pc-linux-gnu)
MIME-Version: 1.0
Content-Type: multipart/signed; micalg=pgp-sha1;
 boundary="Sig_/pREdLAkfJ7Itw51TtQNF_R0"; protocol="application/pgp-signature"
X-Spam-Score: 0.4 (/)
X-Debbugs-Envelope-To: 40744-done
Cc: 40744-done <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

--Sig_/pREdLAkfJ7Itw51TtQNF_R0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

On Sat, 25 Apr 2020 23:33:50 +0200
Bengt Richter <bokr@HIDDEN> wrote:

> Apologies for my faux pas ;-/
>=20
> This was not a guix bug, and you have rightly ignored my report.
> (now submitted to bug-guile, with hopes of nz human acks :)
>=20
> (I guess it will get a new number, so 40744 can be closed?)
>=20
> (BTW, no offense intended in addressing you as "guix/guile
> bug-squashers" ;-/)=20

There is a significant overlap between both groups and all like bugs to
be gone :-)

Bugreport was re-opened under the guile package here:

https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D40855

Closing this one.

Bj=C3=B6rn

--Sig_/pREdLAkfJ7Itw51TtQNF_R0
Content-Type: application/pgp-signature
Content-Description: OpenPGP digital signature

-----BEGIN PGP SIGNATURE-----

iF0EARECAB0WIQQiGUP0np8nb5SZM4K/KGy2WT5f/QUCXqhxCwAKCRC/KGy2WT5f
/eejAJ0b7o/ia86yPuDcHdI95FghWdg40QCbBQvBALiXFfDPffDipXLNemQjY04=
=0lfM
-----END PGP SIGNATURE-----

--Sig_/pREdLAkfJ7Itw51TtQNF_R0--


------------=_1588097342-15286-0--


Message sent:


MIME-Version: 1.0
X-Mailer: MIME-tools 5.505 (Entity 5.505)
X-Loop: help-debbugs@HIDDEN
From: help-debbugs@HIDDEN (GNU bug Tracking System)
To: Bengt Richter <bokr@HIDDEN>
Subject: bug#40744: closed (Re: bug#40744: guile-2.2.4 (integer-length 0)
 erroneously returns 0, not 1)
Message-ID: <handler.40744.D40744.158809730915229.notifdone <at> debbugs.gnu.org>
References: <20200428200810.7d619d27@alma-ubu>
 <20200421130344.GA9369@LionPure>
X-Gnu-PR-Message: they-closed 40744
X-Gnu-PR-Package: guile
Reply-To: 40744 <at> debbugs.gnu.org
Date: Tue, 28 Apr 2020 18:09:02 +0000
Content-Type: multipart/mixed; boundary="----------=_1588097342-15286-1"

This is a multi-part message in MIME format...

------------=_1588097342-15286-1
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset="utf-8"

Your bug report

#40744: guile-2.2.4 (integer-length 0) erroneously returns 0, not 1

which was filed against the guile package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to 40744 <at> debbugs.gnu.org.

--=20
40744: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D40744
GNU Bug Tracking System
Contact help-debbugs@HIDDEN with problems

------------=_1588097342-15286-1
Content-Type: message/rfc822
Content-Disposition: inline
Content-Transfer-Encoding: 7bit

Received: (at 40744-done) by debbugs.gnu.org; 28 Apr 2020 18:08:29 +0000
Received: from localhost ([127.0.0.1]:41424 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1jTUei-0003xZ-BD
	for submit <at> debbugs.gnu.org; Tue, 28 Apr 2020 14:08:28 -0400
Received: from m4s11.vlinux.de ([83.151.27.109]:59022 helo=bjoernhoefling.de)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <bjoern.hoefling@HIDDEN>)
 id 1jTUeS-0003wp-RP
 for 40744-done <at> debbugs.gnu.org; Tue, 28 Apr 2020 14:08:25 -0400
Received: from alma-ubu (p508ACA3F.dip0.t-ipconnect.de [80.138.202.63])
 (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
 (No client certificate requested)
 by bjoernhoefling.de (Postfix) with ESMTPSA id 747483F861;
 Tue, 28 Apr 2020 20:08:11 +0200 (CEST)
Date: Tue, 28 Apr 2020 20:08:10 +0200
From: =?UTF-8?B?QmrDtnJuIEjDtmZsaW5n?= <bjoern.hoefling@HIDDEN>
To: Bengt Richter <bokr@HIDDEN>
Subject: Re: bug#40744: guile-2.2.4 (integer-length 0) erroneously returns
 0, not 1
Message-ID: <20200428200810.7d619d27@alma-ubu>
In-Reply-To: <20200425213350.GA10462@LionPure>
References: <20200421130344.GA9369@LionPure> <20200425213350.GA10462@LionPure>
X-Mailer: Claws Mail 3.16.0 (GTK+ 2.24.32; x86_64-pc-linux-gnu)
MIME-Version: 1.0
Content-Type: multipart/signed; micalg=pgp-sha1;
 boundary="Sig_/pREdLAkfJ7Itw51TtQNF_R0"; protocol="application/pgp-signature"
X-Spam-Score: 0.4 (/)
X-Debbugs-Envelope-To: 40744-done
Cc: 40744-done <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

--Sig_/pREdLAkfJ7Itw51TtQNF_R0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

On Sat, 25 Apr 2020 23:33:50 +0200
Bengt Richter <bokr@HIDDEN> wrote:

> Apologies for my faux pas ;-/
>=20
> This was not a guix bug, and you have rightly ignored my report.
> (now submitted to bug-guile, with hopes of nz human acks :)
>=20
> (I guess it will get a new number, so 40744 can be closed?)
>=20
> (BTW, no offense intended in addressing you as "guix/guile
> bug-squashers" ;-/)=20

There is a significant overlap between both groups and all like bugs to
be gone :-)

Bugreport was re-opened under the guile package here:

https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D40855

Closing this one.

Bj=C3=B6rn

--Sig_/pREdLAkfJ7Itw51TtQNF_R0
Content-Type: application/pgp-signature
Content-Description: OpenPGP digital signature

-----BEGIN PGP SIGNATURE-----

iF0EARECAB0WIQQiGUP0np8nb5SZM4K/KGy2WT5f/QUCXqhxCwAKCRC/KGy2WT5f
/eejAJ0b7o/ia86yPuDcHdI95FghWdg40QCbBQvBALiXFfDPffDipXLNemQjY04=
=0lfM
-----END PGP SIGNATURE-----

--Sig_/pREdLAkfJ7Itw51TtQNF_R0--


------------=_1588097342-15286-1
Content-Type: message/rfc822
Content-Disposition: inline
Content-Transfer-Encoding: 7bit

Received: (at submit) by debbugs.gnu.org; 21 Apr 2020 13:04:12 +0000
Received: from localhost ([127.0.0.1]:49147 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1jQsZM-00015I-V9
	for submit <at> debbugs.gnu.org; Tue, 21 Apr 2020 09:04:12 -0400
Received: from lists.gnu.org ([209.51.188.17]:39940)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <bokr@HIDDEN>) id 1jQsZK-000159-Sx
 for submit <at> debbugs.gnu.org; Tue, 21 Apr 2020 09:04:07 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:45208)
 by lists.gnu.org with esmtp (Exim 4.90_1)
 (envelope-from <bokr@HIDDEN>) id 1jQsZJ-0002OE-Vj
 for bug-guix@HIDDEN; Tue, 21 Apr 2020 09:04:06 -0400
X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00,
 HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H3,
 RCVD_IN_MSPIKE_WL,SPF_PASS autolearn=unavailable autolearn_force=no
 version=3.4.2
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1)
 (envelope-from <bokr@HIDDEN>) id 1jQsZI-0003R9-C7
 for bug-guix@HIDDEN; Tue, 21 Apr 2020 09:04:05 -0400
Received: from imta-36.everyone.net ([216.200.145.36]:53194
 helo=imta-38.everyone.net)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <bokr@HIDDEN>) id 1jQsZG-0003OU-BR
 for bug-guix@HIDDEN; Tue, 21 Apr 2020 09:04:03 -0400
Received: from pps.filterd (omta002.sj2.proofpoint.com [127.0.0.1])
 by imta-38.everyone.net (8.16.0.27/8.16.0.27) with SMTP id 03LD1iSZ014245
 for <bug-guix@HIDDEN>; Tue, 21 Apr 2020 06:03:57 -0700
X-Eon-Originating-Account: i-h_PaSXDAFkwuy2p0jCcvm-XTwSApTPRg-Usrpt6ic
X-Eon-Dm: m0116293.ppops.net
Received: by m0116293.mta.everyone.net (EON-AUTHRELAY2 - 53b92cab) id
 m0116293.5e67f91c.3a7648
 for <bug-guix@HIDDEN>; Tue, 21 Apr 2020 06:03:55 -0700
X-Eon-Sig: AQMHrIJenu874HkkZgIAAAAB,9254880fbaed8d152fcefda3999ec14d
X-Eip: J0zbnjcn_FlGWfQZbncy5_Ug_RcAsNVrjTMlIdScGtI
Date: Tue, 21 Apr 2020 15:03:44 +0200
From: Bengt Richter <bokr@HIDDEN>
To: New-Bug <bug-guix@HIDDEN>
Subject: guile-2.2.4 (integer-length 0) erroneously returns 0, not 1
Message-ID: <20200421130344.GA9369@LionPure>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
User-Agent: Mutt/1.10.1 (2018-07-13)
X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138, 18.0.676
 definitions=2020-04-21_05:2020-04-20,
 2020-04-21 signatures=0
X-Proofpoint-Spam-Details: rule=notspam policy=default score=0
 priorityscore=1501 malwarescore=0
 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1034
 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0
 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-2002250000
 definitions=main-2004210104
Received-SPF: pass client-ip=216.200.145.36; envelope-from=bokr@HIDDEN;
 helo=imta-38.everyone.net
X-detected-operating-system: by eggs.gnu.org: First seen = 2020/04/21 09:03:58
X-ACL-Warn: Detected OS   = Linux 3.x [generic]
X-Received-From: 216.200.145.36
X-Spam-Score: 0.5 (/)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Reply-To: Bengt Richter <bokr@HIDDEN>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.4 (-)

Hello guix/guile bug-squashers,

The tl;dr is:
    (integer-length 0) should agree with:
    (string-length (number->string 0 2)) =-> 1
        -- and not:   (integer-length 0) =-> 0

The integer length in bits (short for binary digits :)
is the number digits required to write the integer value
in conventional big-endian digit order, signifying coefficients
of successive powers of the radix used.

This applies irrespective of the radix. Thus "11" in decimal is
  "1*10^1 + 1*10^0"
or hex is
  "11*16^0"
or binary is
  "1*2^1 + 1*2^0"

So, the crux of the argument is that it takes one digit to write
either 1 or 0:
--8<---------------cut here---------------start------------->8---
Inputs: 1 (radix 10, decimal value unsigned 1) (output radix 2)
  Number as radix-2 glyph{0..1} string (unsigned)
  "1"
  Number as glyphs representing coefficient values of radix polynomial for number value:
  ("1")
  (1) -- corresponding coefficient values
  Number as polynomial expression:
  "1*2^0"
  (1) -- corresponding term values
  1 -- sum of term values
  The following should be equal to guile's (integer-length 1):
  1 integer-digit (radix 2)
--8<---------------cut here---------------end--------------->8---

--8<---------------cut here---------------start------------->8---
Inputs: 0 (radix 10, decimal value unsigned 0) (output radix 2)
  Number as radix-2 glyph{0..1} string (unsigned)
  "0"
  Number as glyphs representing coefficient values of radix polynomial for number value:
  ("0")
  (0) -- corresponding coefficient values
  Number as polynomial expression:
  "0*2^0"
  (0) -- corresponding term values
  0 -- sum of term values
  The following should be equal to guile's (integer-length 0):
  1 integer-digit (radix 2)
--8<---------------cut here---------------end--------------->8---

BTW, this works for signed numbers as well, if you use a complement
representation making the sign digit 0 for positive and radix-1 for
negative (thus 0 and 1 for radix 2, and e.g. 0 and f for radix 16).

Decimal is just another radix:

Inputs: -11 (radix 10, decimal value minus 11) (output radix 10)
  Number as radix-10 glyph{0..9} string (radix-complement -sign prefix)
  "989" (complement notation)
   ^--(note that 0 and "9" (radix10 -1) are sign digits for 0 and -1 coefficient values in the polynomial)
  Number as glyphs representing coefficient values of radix polynomial for number value:
  ("-1" "8" "9")
  (-1 8 9) -- corresponding coefficient values
  Number as polynomial expression:
  "-1*10^2 + 8*10^1 + 9*10^0"
  (-100 80 9) -- corresponding term values
  -11 -- sum of term values
  Tip: for guile integer-length, enter unsigned value with output radix 2
  3 integer-digits (radix 10)

The extreme for this version is radix 36:

Inputs: -11 (radix 36, decimal value minus 37) (output radix 36)
  Number as radix-36 glyph{0..z} string (radix-complement -sign prefix)
  "zyz" (complement notation)
   ^--(note that 0 and "z" (radix36 -1) are sign digits for 0 and -1 coefficient values in the polynomial)
  Number as glyphs representing coefficient values of radix polynomial for number value:
  ("-1" "y" "z")
  (-1 34 35) -- corresponding coefficient values
  Number as polynomial expression:
  "-1*36^2 + 34*36^1 + 35*36^0"
  (-1296 1224 35) -- corresponding term values
  -37 -- sum of term values
  Tip: for guile integer-length, enter unsigned value with output radix 2
  3 integer-digits (radix 36)

I got a little carried away exploring the complement notation, and wrote
a thing to explain the meanings. Please copy snip to int2poly and chmod 755 it.
Then run once without args for usage help.

I hope it will convince you that guile (integer-length 0) should be 1 ;-)

--8<---------------cut here---------------start------------->8---
#!/usr/bin/env -S guile -e main -s
!#
;; run without arguments for usage, or read below
;; int2poly-0.1.0 -- 2020-04-21 

(use-modules (ice-9 format)
	     (ice-9 regex))

(define self (basename (car (command-line))))
(define verbose #f)

(define (usage)
  (begin
    (let*((selfxxx (basename (car (command-line)))))
      (begin
	(format (current-error-port)
		"Usage:
        ~a  [-v ] | NUMSTR  [out-radix] [inp-radix]
        where *-radix are entered in decimal, and
        out-radix defaults to 2 and inp-radix defaults to 10,
        but may set independently to 2..36 to demo generality.

        -v for verbose output explanations

        NUMSTR will be written in radix digits representing
        polynomial coefficients, which is presented in series terms
        and evaluated back to the original number.

        The NUMSTR character set is the same as for (number->string radix)
        but could be any chosen set of distinct glyphs for values {0..<radix -1>}.

        guile integer-length can be considered a special case of
        coefficient count for radix 2, which is  printed in the last
        line of output as \"N integer-digits (radix N)\n"
		self ))
      (if (= (integer-length 0) 0)
	  (begin
	  (format #t "\nGuile[1] bug:
    (integer-length 0) should agree with:
    (string-length (number->string 0 2)) =-> ~s
        -- and not:   (integer-length 0) =-> ~s
    And it should agree with integer-digits for ~a 1 and ~a 0
    Try ~a 0, and note that it is 1 for any radix 2-36
    and numstr is 10 for ~a radix radix also for any radix ;-)\n\n"
		  (string-length (number->string 0 2))
		  (integer-length 0)
		  self self self self)
	  (display "[1] ----\n")
	  (system "guile -v")
	  (display "----\n ")
	  )))))

(define (main argl)
  (begin
    (set! argl (cdr argl))
    (if (not (pair? argl)) (begin (usage) (exit)))
    (if (string=? "-v" (car argl)) (begin (set! verbose #t) (set! argl (cdr argl))))
    (if (not (pair? argl)) (begin (usage) (exit)))
    (let*((matstr (string-match "[0-9a-z]+" (string-join argl " "))) ;; for <prefix><substring><suffix>
	  (sgnstr (match:prefix matstr))    ;; [<sign>]
	  (absstr (match:substring matstr)) ;;         <inpnum> [<out-radix>] [<in-radix>] 

	  (matst2 (string-match "[0-9]+" (match:suffix matstr))) ;; demo radix (spec in decimal)  [<out-radix>] [<inp-radix>]
          (radix (if matst2 (string->number (match:substring matst2)) 2)) ;; default demo radix is 2

	  (matst3 (if matst2 (string-match "[0-9]+" (match:suffix matst2)) #f)) ;;                                [<inp-radix>]
	  (iradix (if matst3 (string->number (match:substring matst3)) 10)) ;; default input radix 10

	  (absnum (string->number absstr iradix)) ;; abs math value of input
	  (abswid (string-length (number->string absnum radix)))
	  (radixp (integer-expt radix (+ 1 abswid))) ;; 2nd bit above msb of absnum
	  (usenum (if (string=? "-" sgnstr) (- radixp absnum) (+ radixp absnum))) ;; 10abs or 10000-abs
	                                                                          ;;          _1xyx
	                                                                          ;;      or  10000 if abs=0
	  (numstr1 (number->string usenum radix))
	  (numoff (if (string=? "" sgnstr)
		      2
		      (- (string-length numstr1) (+ 1 abswid))))

	  (numstr (substring numstr1 numoff))
	  (coeffs (map match:substring  (list-matches "(.)" numstr)))
	  (coeffs (if (string=? "" sgnstr)
		      coeffs
		      (begin
			(if (char=? (string-ref numstr 0)
				    (string-ref (number->string (- radix 1) radix) 0))
			    (cons "-1" (cdr coeffs))
			    coeffs))))
	  (coeffv (map (lambda (s) (string->number s radix)) coeffs))
	  (ncoeff (length coeffs))
	  (terms (string-join (reverse (map (lambda (coeff power)
				 (begin (format #f "~d*~d^~d" coeff radix power))) (reverse coeffv) (iota ncoeff))) " + "))
	  (termv (reverse (map (lambda (coeff power)
				 (begin (* coeff (integer-expt radix power)))) (reverse coeffv) (iota ncoeff))))
	  (polyv (apply + termv))

	  (signword (begin (cond
			    ((string=? "" sgnstr) "unsigned")
			    ((string=? "+" sgnstr) "plus")
			    ((string=? "-" sgnstr) "minus")
			    (else (throw 'int2poly "bad sign:" sgnstr)))))
	  (sgnnote (begin (cond
			    ((string=? "" sgnstr) "(unsigned)")
			    ((string=? "+" sgnstr) "(radix-complement +sign prefix)")
			    ((string=? "-" sgnstr) "(radix-complement -sign prefix)")
			    (else (throw 'int2poly "bad sign:" sgnstr)))))
	  )
      (begin
	(format #t "Inputs: ~a~a (radix ~s, decimal value ~a ~s) (output radix ~s)\n" sgnstr absstr iradix signword absnum radix)
        (if verbose (format #t "  Number as radix-~s glyph{~a..~a} string ~a\n"
	 		    radix  (number->string 0 radix) (number->string (- radix 1) radix)  sgnnote))
	(format #t "  ~s~a\n" numstr (if (string=? "" sgnstr) "" " (complement notation)"))
	(if (and verbose (not (string=? sgnstr "")))
	    (format #t "   ^--(note that 0 and ~s (radix~a -1) are sign digits for 0 and -1 coefficient values in the polynomial)\n"
							     (number->string (- radix 1) radix) radix))
	(format #t "~a  ~s\n" (if verbose "  Number as glyphs representing coefficient values of radix polynomial for number value:\n" "") coeffs)
	(format #t "  ~s~a\n" coeffv (if verbose  " -- corresponding coefficient values" ""))
	(format #t "~a  ~s\n" (if verbose "  Number as polynomial expression:\n" "") terms)
	(format #t "  ~s~a\n" termv (if verbose " -- corresponding term values" ""))
	(format #t "  ~s~a\n" polyv (if verbose " -- sum of term values" ""))
	(if verbose
	    (if (and (= radix 2) (string=? sgnstr ""))
		(format #t "  The following should be equal to guile's (integer-length ~s):\n" absnum)
		(format #t "  Tip: for guile integer-length, enter unsigned value with output radix 2\n")))
	(format #t "  ~s integer-digit~a (radix ~a)\n" ncoeff (if (> ncoeff 1) "s" "") radix))
      )))
--8<---------------cut here---------------end--------------->8---

-- 
Regards,
Bengt Richter



------------=_1588097342-15286-1--


Message sent:


MIME-Version: 1.0
X-Mailer: MIME-tools 5.505 (Entity 5.505)
X-Loop: help-debbugs@HIDDEN
From: help-debbugs@HIDDEN (GNU bug Tracking System)
To: =?UTF-8?Q?Bj=C3=B6rn_?= =?UTF-8?Q?H=C3=B6fling?=
 <bjoern.hoefling@HIDDEN>
Subject: bug#40855: closed (integer-length 0 should be 1)
CC: tracker <at> debbugs.gnu.org
Message-ID: <handler.40855.D40744.158809730915229.ackdone <at> debbugs.gnu.org>
References: <20200428200810.7d619d27@alma-ubu>
 <20200425211540.GA10315@LionPure>
X-Gnu-PR-Message: closed 40855
X-Gnu-PR-Package: guile
Date: Tue, 28 Apr 2020 18:09:03 +0000
Content-Type: multipart/mixed; boundary="----------=_1588097343-15286-2"

This is a multi-part message in MIME format...

------------=_1588097343-15286-2
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=utf-8

Your message dated Tue, 28 Apr 2020 20:08:10 +0200
with message-id <20200428200810.7d619d27@alma-ubu>
and subject line Re: bug#40744: guile-2.2.4 (integer-length 0) erroneously =
returns 0, not 1
has caused the debbugs.gnu.org bug report #40744,
regarding integer-length 0 should be 1
to be marked as done.

(If you believe you have received this mail in error, please contact
help-debbugs@HIDDEN)


--=20
40744: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D40744
GNU Bug Tracking System
Contact help-debbugs@HIDDEN with problems

------------=_1588097343-15286-2
Content-Type: message/rfc822
Content-Disposition: inline
Content-Transfer-Encoding: 7bit

Received: (at submit) by debbugs.gnu.org; 25 Apr 2020 21:16:08 +0000
Received: from localhost ([127.0.0.1]:60492 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1jSS9f-0007Xa-W2
	for submit <at> debbugs.gnu.org; Sat, 25 Apr 2020 17:16:08 -0400
Received: from lists.gnu.org ([209.51.188.17]:39670)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <bokr@HIDDEN>) id 1jSS9d-0007XQ-V0
 for submit <at> debbugs.gnu.org; Sat, 25 Apr 2020 17:16:06 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:51614)
 by lists.gnu.org with esmtp (Exim 4.90_1)
 (envelope-from <bokr@HIDDEN>) id 1jSS9d-0003NO-5E
 for bug-guile@HIDDEN; Sat, 25 Apr 2020 17:16:05 -0400
X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00,
 HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_LOW,SPF_PASS
 autolearn=unavailable autolearn_force=no version=3.4.2
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1)
 (envelope-from <bokr@HIDDEN>) id 1jSS9c-0007kL-20
 for bug-guile@HIDDEN; Sat, 25 Apr 2020 17:16:04 -0400
Received: from imta-37.everyone.net ([216.200.145.37]:52510
 helo=imta-38.everyone.net)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <bokr@HIDDEN>) id 1jSS9b-0007gP-BF
 for bug-guile@HIDDEN; Sat, 25 Apr 2020 17:16:03 -0400
Received: from pps.filterd (localhost.localdomain [127.0.0.1])
 by imta-38.everyone.net (8.16.0.27/8.16.0.27) with SMTP id 03PLEpsE025276
 for <bug-guile@HIDDEN>; Sat, 25 Apr 2020 14:15:54 -0700
X-Eon-Originating-Account: GvtrA4CWB31DKDYPaXpK0cj_iskPsz-TZpyEirsFbqk
X-Eon-Dm: m0116293.ppops.net
Received: by m0116293.mta.everyone.net (EON-AUTHRELAY2 - 5a81c6e6) id
 m0116293.5e67f91c.41853c
 for <bug-guile@HIDDEN>; Sat, 25 Apr 2020 14:15:52 -0700
X-Eon-Sig: AQMHrIJepKiIKitHjAIAAAAB,25c1be2c3116f6932bf29f64b4041e7a
X-Eip: zypbXhRl0sG6PksXuoQmZDY18vZjJBQ87PQLQfYDzM8
Date: Sat, 25 Apr 2020 23:15:40 +0200
From: Bengt Richter <bokr@HIDDEN>
To: bug-guile@HIDDEN
Subject: integer-length 0 should be 1
Message-ID: <20200425211540.GA10315@LionPure>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
User-Agent: Mutt/1.10.1 (2018-07-13)
X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138, 18.0.676
 definitions=2020-04-25_13:2020-04-24,
 2020-04-25 signatures=0
X-Proofpoint-Spam-Details: rule=notspam policy=default score=0
 priorityscore=1501 malwarescore=0
 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1034
 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0
 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-2002250000
 definitions=main-2004250186
Received-SPF: pass client-ip=216.200.145.37; envelope-from=bokr@HIDDEN;
 helo=imta-38.everyone.net
X-detected-operating-system: by eggs.gnu.org: First seen = 2020/04/25 17:15:54
X-ACL-Warn: Detected OS   = Linux 3.x [generic]
X-Received-From: 216.200.145.37
X-Spam-Score: -1.1 (-)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Reply-To: Bengt Richter <bokr@HIDDEN>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.1 (--)

I'm hoping this is the right place to report this bug :)

To reproduce, guile -c '(format #t "~s\n" (integer-length 0))'
Expected result if correct: 1
Observed result: 0

The following is to support the opinion that 1 is the correct result,
and to explore how integer "length" generalizes to other radixes and
also signed number writing other than sign-magnitude.

Feel free to skip the following if of no interest :)

The tl;dr is:
    (integer-length 0) should agree with:
    (string-length (number->string 0 2)) =-> 1
        -- and not:   (integer-length 0) =-> 0

The integer length in bits (short for binary digits :)
is the number digits required to write the integer value
in conventional big-endian digit order, signifying coefficients
of successive powers of the radix used.

This applies irrespective of the radix. Thus "11" in decimal is
  "1*10^1 + 1*10^0"
or hex is
  "11*16^0"
or binary is
  "1*2^1 + 1*2^0"

So, the crux of the argument is that it takes one digit to write
either 1 or 0:
--8<---------------cut here---------------start------------->8---
Inputs: 1 (radix 10, decimal value unsigned 1) (output radix 2)
  Number as radix-2 glyph{0..1} string (unsigned)
  "1"
  Number as glyphs representing coefficient values of radix polynomial for number value:
  ("1")
  (1) -- corresponding coefficient values
  Number as polynomial expression:
  "1*2^0"
  (1) -- corresponding term values
  1 -- sum of term values
  The following should be equal to guile's (integer-length 1):
  1 integer-digit (radix 2)
--8<---------------cut here---------------end--------------->8---

--8<---------------cut here---------------start------------->8---
Inputs: 0 (radix 10, decimal value unsigned 0) (output radix 2)
  Number as radix-2 glyph{0..1} string (unsigned)
  "0"
  Number as glyphs representing coefficient values of radix polynomial for number value:
  ("0")
  (0) -- corresponding coefficient values
  Number as polynomial expression:
  "0*2^0"
  (0) -- corresponding term values
  0 -- sum of term values
  The following should be equal to guile's (integer-length 0):
  1 integer-digit (radix 2)
--8<---------------cut here---------------end--------------->8---

BTW, this works for signed numbers as well, if you use a complement
representation making the sign digit 0 for positive and radix-1 for
negative (thus 0 and 1 for radix 2, and e.g. 0 and f for radix 16).

Decimal is just another radix:

Inputs: -11 (radix 10, decimal value minus 11) (output radix 10)
  Number as radix-10 glyph{0..9} string (radix-complement -sign prefix)
  "989" (complement notation)
   ^--(note that 0 and "9" (radix10 -1) are sign digits for 0 and -1 coefficient values in the polynomial)
  Number as glyphs representing coefficient values of radix polynomial for number value:
  ("-1" "8" "9")
  (-1 8 9) -- corresponding coefficient values
  Number as polynomial expression:
  "-1*10^2 + 8*10^1 + 9*10^0"
  (-100 80 9) -- corresponding term values
  -11 -- sum of term values
  Tip: for guile integer-length, enter unsigned value with output radix 2
  3 integer-digits (radix 10)

The extreme for this version is radix 36:

Inputs: -11 (radix 36, decimal value minus 37) (output radix 36)
  Number as radix-36 glyph{0..z} string (radix-complement -sign prefix)
  "zyz" (complement notation)
   ^--(note that 0 and "z" (radix36 -1) are sign digits for 0 and -1 coefficient values in the polynomial)
  Number as glyphs representing coefficient values of radix polynomial for number value:
  ("-1" "y" "z")
  (-1 34 35) -- corresponding coefficient values
  Number as polynomial expression:
  "-1*36^2 + 34*36^1 + 35*36^0"
  (-1296 1224 35) -- corresponding term values
  -37 -- sum of term values
  Tip: for guile integer-length, enter unsigned value with output radix 2
  3 integer-digits (radix 36)

I got a little carried away exploring the complement notation, and wrote
a thing to explain the meanings. Please copy snip to int2poly and chmod 755 it.
Then run once without args for usage help.

I hope it will convince you that guile (integer-length 0) should be 1 ;-)

--8<---------------cut here---------------start------------->8---
#!/usr/bin/env -S guile -e main -s
!#
;; run without arguments for usage, or read below
;; int2poly-0.1.0 -- 2020-04-21 

(use-modules (ice-9 format)
	     (ice-9 regex))

(define self (basename (car (command-line))))
(define verbose #f)

(define (usage)
  (begin
    (let*((selfxxx (basename (car (command-line)))))
      (begin
	(format (current-error-port)
		"Usage:
        ~a  [-v ] | NUMSTR  [out-radix] [inp-radix]
        where *-radix are entered in decimal, and
        out-radix defaults to 2 and inp-radix defaults to 10,
        but may set independently to 2..36 to demo generality.

        -v for verbose output explanations

        NUMSTR will be written in radix digits representing
        polynomial coefficients, which is presented in series terms
        and evaluated back to the original number.

        The NUMSTR character set is the same as for (number->string radix)
        but could be any chosen set of distinct glyphs for values {0..<radix -1>}.

        guile integer-length can be considered a special case of
        coefficient count for radix 2, which is  printed in the last
        line of output as \"N integer-digits (radix N)\n"
		self ))
      (if (= (integer-length 0) 0)
	  (begin
	  (format #t "\nGuile[1] bug:
    (integer-length 0) should agree with:
    (string-length (number->string 0 2)) =-> ~s
        -- and not:   (integer-length 0) =-> ~s
    And it should agree with integer-digits for ~a 1 and ~a 0
    Try ~a 0, and note that it is 1 for any radix 2-36
    and numstr is 10 for ~a radix radix also for any radix ;-)\n\n"
		  (string-length (number->string 0 2))
		  (integer-length 0)
		  self self self self)
	  (display "[1] ----\n")
	  (system "guile -v")
	  (display "----\n ")
	  )))))

(define (main argl)
  (begin
    (set! argl (cdr argl))
    (if (not (pair? argl)) (begin (usage) (exit)))
    (if (string=? "-v" (car argl)) (begin (set! verbose #t) (set! argl (cdr argl))))
    (if (not (pair? argl)) (begin (usage) (exit)))
    (let*((matstr (string-match "[0-9a-z]+" (string-join argl " "))) ;; for <prefix><substring><suffix>
	  (sgnstr (match:prefix matstr))    ;; [<sign>]
	  (absstr (match:substring matstr)) ;;         <inpnum> [<out-radix>] [<in-radix>] 

	  (matst2 (string-match "[0-9]+" (match:suffix matstr))) ;; demo radix (spec in decimal)  [<out-radix>] [<inp-radix>]
          (radix (if matst2 (string->number (match:substring matst2)) 2)) ;; default demo radix is 2

	  (matst3 (if matst2 (string-match "[0-9]+" (match:suffix matst2)) #f)) ;;                                [<inp-radix>]
	  (iradix (if matst3 (string->number (match:substring matst3)) 10)) ;; default input radix 10

	  (absnum (string->number absstr iradix)) ;; abs math value of input
	  (abswid (string-length (number->string absnum radix)))
	  (radixp (integer-expt radix (+ 1 abswid))) ;; 2nd bit above msb of absnum
	  (usenum (if (string=? "-" sgnstr) (- radixp absnum) (+ radixp absnum))) ;; 10abs or 10000-abs
	                                                                          ;;          _1xyx
	                                                                          ;;      or  10000 if abs=0
	  (numstr1 (number->string usenum radix))
	  (numoff (if (string=? "" sgnstr)
		      2
		      (- (string-length numstr1) (+ 1 abswid))))

	  (numstr (substring numstr1 numoff))
	  (coeffs (map match:substring  (list-matches "(.)" numstr)))
	  (coeffs (if (string=? "" sgnstr)
		      coeffs
		      (begin
			(if (char=? (string-ref numstr 0)
				    (string-ref (number->string (- radix 1) radix) 0))
			    (cons "-1" (cdr coeffs))
			    coeffs))))
	  (coeffv (map (lambda (s) (string->number s radix)) coeffs))
	  (ncoeff (length coeffs))
	  (terms (string-join (reverse (map (lambda (coeff power)
				 (begin (format #f "~d*~d^~d" coeff radix power))) (reverse coeffv) (iota ncoeff))) " + "))
	  (termv (reverse (map (lambda (coeff power)
				 (begin (* coeff (integer-expt radix power)))) (reverse coeffv) (iota ncoeff))))
	  (polyv (apply + termv))

	  (signword (begin (cond
			    ((string=? "" sgnstr) "unsigned")
			    ((string=? "+" sgnstr) "plus")
			    ((string=? "-" sgnstr) "minus")
			    (else (throw 'int2poly "bad sign:" sgnstr)))))
	  (sgnnote (begin (cond
			    ((string=? "" sgnstr) "(unsigned)")
			    ((string=? "+" sgnstr) "(radix-complement +sign prefix)")
			    ((string=? "-" sgnstr) "(radix-complement -sign prefix)")
			    (else (throw 'int2poly "bad sign:" sgnstr)))))
	  )
      (begin
	(format #t "Inputs: ~a~a (radix ~s, decimal value ~a ~s) (output radix ~s)\n" sgnstr absstr iradix signword absnum radix)
        (if verbose (format #t "  Number as radix-~s glyph{~a..~a} string ~a\n"
	 		    radix  (number->string 0 radix) (number->string (- radix 1) radix)  sgnnote))
	(format #t "  ~s~a\n" numstr (if (string=? "" sgnstr) "" " (complement notation)"))
	(if (and verbose (not (string=? sgnstr "")))
	    (format #t "   ^--(note that 0 and ~s (radix~a -1) are sign digits for 0 and -1 coefficient values in the polynomial)\n"
							     (number->string (- radix 1) radix) radix))
	(format #t "~a  ~s\n" (if verbose "  Number as glyphs representing coefficient values of radix polynomial for number value:\n" "") coeffs)
	(format #t "  ~s~a\n" coeffv (if verbose  " -- corresponding coefficient values" ""))
	(format #t "~a  ~s\n" (if verbose "  Number as polynomial expression:\n" "") terms)
	(format #t "  ~s~a\n" termv (if verbose " -- corresponding term values" ""))
	(format #t "  ~s~a\n" polyv (if verbose " -- sum of term values" ""))
	(if verbose
	    (if (and (= radix 2) (string=? sgnstr ""))
		(format #t "  The following should be equal to guile's (integer-length ~s):\n" absnum)
		(format #t "  Tip: for guile integer-length, enter unsigned value with output radix 2\n")))
	(format #t "  ~s integer-digit~a (radix ~a)\n" ncoeff (if (> ncoeff 1) "s" "") radix))
      )))
--8<---------------cut here---------------end--------------->8---

-- 
Regards,
Bengt Richter



------------=_1588097343-15286-2
Content-Type: message/rfc822
Content-Disposition: inline
Content-Transfer-Encoding: 7bit

Received: (at 40744-done) by debbugs.gnu.org; 28 Apr 2020 18:08:29 +0000
Received: from localhost ([127.0.0.1]:41424 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1jTUei-0003xZ-BD
	for submit <at> debbugs.gnu.org; Tue, 28 Apr 2020 14:08:28 -0400
Received: from m4s11.vlinux.de ([83.151.27.109]:59022 helo=bjoernhoefling.de)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <bjoern.hoefling@HIDDEN>)
 id 1jTUeS-0003wp-RP
 for 40744-done <at> debbugs.gnu.org; Tue, 28 Apr 2020 14:08:25 -0400
Received: from alma-ubu (p508ACA3F.dip0.t-ipconnect.de [80.138.202.63])
 (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
 (No client certificate requested)
 by bjoernhoefling.de (Postfix) with ESMTPSA id 747483F861;
 Tue, 28 Apr 2020 20:08:11 +0200 (CEST)
Date: Tue, 28 Apr 2020 20:08:10 +0200
From: =?UTF-8?B?QmrDtnJuIEjDtmZsaW5n?= <bjoern.hoefling@HIDDEN>
To: Bengt Richter <bokr@HIDDEN>
Subject: Re: bug#40744: guile-2.2.4 (integer-length 0) erroneously returns
 0, not 1
Message-ID: <20200428200810.7d619d27@alma-ubu>
In-Reply-To: <20200425213350.GA10462@LionPure>
References: <20200421130344.GA9369@LionPure> <20200425213350.GA10462@LionPure>
X-Mailer: Claws Mail 3.16.0 (GTK+ 2.24.32; x86_64-pc-linux-gnu)
MIME-Version: 1.0
Content-Type: multipart/signed; micalg=pgp-sha1;
 boundary="Sig_/pREdLAkfJ7Itw51TtQNF_R0"; protocol="application/pgp-signature"
X-Spam-Score: 0.4 (/)
X-Debbugs-Envelope-To: 40744-done
Cc: 40744-done <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

--Sig_/pREdLAkfJ7Itw51TtQNF_R0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

On Sat, 25 Apr 2020 23:33:50 +0200
Bengt Richter <bokr@HIDDEN> wrote:

> Apologies for my faux pas ;-/
>=20
> This was not a guix bug, and you have rightly ignored my report.
> (now submitted to bug-guile, with hopes of nz human acks :)
>=20
> (I guess it will get a new number, so 40744 can be closed?)
>=20
> (BTW, no offense intended in addressing you as "guix/guile
> bug-squashers" ;-/)=20

There is a significant overlap between both groups and all like bugs to
be gone :-)

Bugreport was re-opened under the guile package here:

https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D40855

Closing this one.

Bj=C3=B6rn

--Sig_/pREdLAkfJ7Itw51TtQNF_R0
Content-Type: application/pgp-signature
Content-Description: OpenPGP digital signature

-----BEGIN PGP SIGNATURE-----

iF0EARECAB0WIQQiGUP0np8nb5SZM4K/KGy2WT5f/QUCXqhxCwAKCRC/KGy2WT5f
/eejAJ0b7o/ia86yPuDcHdI95FghWdg40QCbBQvBALiXFfDPffDipXLNemQjY04=
=0lfM
-----END PGP SIGNATURE-----

--Sig_/pREdLAkfJ7Itw51TtQNF_R0--


------------=_1588097343-15286-2--


Message sent:


MIME-Version: 1.0
X-Mailer: MIME-tools 5.505 (Entity 5.505)
X-Loop: help-debbugs@HIDDEN
From: help-debbugs@HIDDEN (GNU bug Tracking System)
To: Bengt Richter <bokr@HIDDEN>
Subject: bug#40855: closed (Re: bug#40744: guile-2.2.4 (integer-length 0)
 erroneously returns 0, not 1)
Message-ID: <handler.40855.D40744.158809730915229.notifdone <at> debbugs.gnu.org>
References: <20200428200810.7d619d27@alma-ubu>
 <20200425211540.GA10315@LionPure>
X-Gnu-PR-Message: they-closed 40855
X-Gnu-PR-Package: guile
Reply-To: 40855 <at> debbugs.gnu.org
Date: Tue, 28 Apr 2020 18:09:03 +0000
Content-Type: multipart/mixed; boundary="----------=_1588097343-15286-3"

This is a multi-part message in MIME format...

------------=_1588097343-15286-3
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset="utf-8"

Your bug report

#40744: integer-length 0 should be 1

which was filed against the guile package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to 40855 <at> debbugs.gnu.org.

--=20
40744: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D40744
GNU Bug Tracking System
Contact help-debbugs@HIDDEN with problems

------------=_1588097343-15286-3
Content-Type: message/rfc822
Content-Disposition: inline
Content-Transfer-Encoding: 7bit

Received: (at 40744-done) by debbugs.gnu.org; 28 Apr 2020 18:08:29 +0000
Received: from localhost ([127.0.0.1]:41424 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1jTUei-0003xZ-BD
	for submit <at> debbugs.gnu.org; Tue, 28 Apr 2020 14:08:28 -0400
Received: from m4s11.vlinux.de ([83.151.27.109]:59022 helo=bjoernhoefling.de)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <bjoern.hoefling@HIDDEN>)
 id 1jTUeS-0003wp-RP
 for 40744-done <at> debbugs.gnu.org; Tue, 28 Apr 2020 14:08:25 -0400
Received: from alma-ubu (p508ACA3F.dip0.t-ipconnect.de [80.138.202.63])
 (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
 (No client certificate requested)
 by bjoernhoefling.de (Postfix) with ESMTPSA id 747483F861;
 Tue, 28 Apr 2020 20:08:11 +0200 (CEST)
Date: Tue, 28 Apr 2020 20:08:10 +0200
From: =?UTF-8?B?QmrDtnJuIEjDtmZsaW5n?= <bjoern.hoefling@HIDDEN>
To: Bengt Richter <bokr@HIDDEN>
Subject: Re: bug#40744: guile-2.2.4 (integer-length 0) erroneously returns
 0, not 1
Message-ID: <20200428200810.7d619d27@alma-ubu>
In-Reply-To: <20200425213350.GA10462@LionPure>
References: <20200421130344.GA9369@LionPure> <20200425213350.GA10462@LionPure>
X-Mailer: Claws Mail 3.16.0 (GTK+ 2.24.32; x86_64-pc-linux-gnu)
MIME-Version: 1.0
Content-Type: multipart/signed; micalg=pgp-sha1;
 boundary="Sig_/pREdLAkfJ7Itw51TtQNF_R0"; protocol="application/pgp-signature"
X-Spam-Score: 0.4 (/)
X-Debbugs-Envelope-To: 40744-done
Cc: 40744-done <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

--Sig_/pREdLAkfJ7Itw51TtQNF_R0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

On Sat, 25 Apr 2020 23:33:50 +0200
Bengt Richter <bokr@HIDDEN> wrote:

> Apologies for my faux pas ;-/
>=20
> This was not a guix bug, and you have rightly ignored my report.
> (now submitted to bug-guile, with hopes of nz human acks :)
>=20
> (I guess it will get a new number, so 40744 can be closed?)
>=20
> (BTW, no offense intended in addressing you as "guix/guile
> bug-squashers" ;-/)=20

There is a significant overlap between both groups and all like bugs to
be gone :-)

Bugreport was re-opened under the guile package here:

https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D40855

Closing this one.

Bj=C3=B6rn

--Sig_/pREdLAkfJ7Itw51TtQNF_R0
Content-Type: application/pgp-signature
Content-Description: OpenPGP digital signature

-----BEGIN PGP SIGNATURE-----

iF0EARECAB0WIQQiGUP0np8nb5SZM4K/KGy2WT5f/QUCXqhxCwAKCRC/KGy2WT5f
/eejAJ0b7o/ia86yPuDcHdI95FghWdg40QCbBQvBALiXFfDPffDipXLNemQjY04=
=0lfM
-----END PGP SIGNATURE-----

--Sig_/pREdLAkfJ7Itw51TtQNF_R0--


------------=_1588097343-15286-3
Content-Type: message/rfc822
Content-Disposition: inline
Content-Transfer-Encoding: 7bit

Received: (at submit) by debbugs.gnu.org; 25 Apr 2020 21:16:08 +0000
Received: from localhost ([127.0.0.1]:60492 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1jSS9f-0007Xa-W2
	for submit <at> debbugs.gnu.org; Sat, 25 Apr 2020 17:16:08 -0400
Received: from lists.gnu.org ([209.51.188.17]:39670)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <bokr@HIDDEN>) id 1jSS9d-0007XQ-V0
 for submit <at> debbugs.gnu.org; Sat, 25 Apr 2020 17:16:06 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:51614)
 by lists.gnu.org with esmtp (Exim 4.90_1)
 (envelope-from <bokr@HIDDEN>) id 1jSS9d-0003NO-5E
 for bug-guile@HIDDEN; Sat, 25 Apr 2020 17:16:05 -0400
X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00,
 HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_LOW,SPF_PASS
 autolearn=unavailable autolearn_force=no version=3.4.2
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1)
 (envelope-from <bokr@HIDDEN>) id 1jSS9c-0007kL-20
 for bug-guile@HIDDEN; Sat, 25 Apr 2020 17:16:04 -0400
Received: from imta-37.everyone.net ([216.200.145.37]:52510
 helo=imta-38.everyone.net)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <bokr@HIDDEN>) id 1jSS9b-0007gP-BF
 for bug-guile@HIDDEN; Sat, 25 Apr 2020 17:16:03 -0400
Received: from pps.filterd (localhost.localdomain [127.0.0.1])
 by imta-38.everyone.net (8.16.0.27/8.16.0.27) with SMTP id 03PLEpsE025276
 for <bug-guile@HIDDEN>; Sat, 25 Apr 2020 14:15:54 -0700
X-Eon-Originating-Account: GvtrA4CWB31DKDYPaXpK0cj_iskPsz-TZpyEirsFbqk
X-Eon-Dm: m0116293.ppops.net
Received: by m0116293.mta.everyone.net (EON-AUTHRELAY2 - 5a81c6e6) id
 m0116293.5e67f91c.41853c
 for <bug-guile@HIDDEN>; Sat, 25 Apr 2020 14:15:52 -0700
X-Eon-Sig: AQMHrIJepKiIKitHjAIAAAAB,25c1be2c3116f6932bf29f64b4041e7a
X-Eip: zypbXhRl0sG6PksXuoQmZDY18vZjJBQ87PQLQfYDzM8
Date: Sat, 25 Apr 2020 23:15:40 +0200
From: Bengt Richter <bokr@HIDDEN>
To: bug-guile@HIDDEN
Subject: integer-length 0 should be 1
Message-ID: <20200425211540.GA10315@LionPure>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
User-Agent: Mutt/1.10.1 (2018-07-13)
X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138, 18.0.676
 definitions=2020-04-25_13:2020-04-24,
 2020-04-25 signatures=0
X-Proofpoint-Spam-Details: rule=notspam policy=default score=0
 priorityscore=1501 malwarescore=0
 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1034
 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0
 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-2002250000
 definitions=main-2004250186
Received-SPF: pass client-ip=216.200.145.37; envelope-from=bokr@HIDDEN;
 helo=imta-38.everyone.net
X-detected-operating-system: by eggs.gnu.org: First seen = 2020/04/25 17:15:54
X-ACL-Warn: Detected OS   = Linux 3.x [generic]
X-Received-From: 216.200.145.37
X-Spam-Score: -1.1 (-)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Reply-To: Bengt Richter <bokr@HIDDEN>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.1 (--)

I'm hoping this is the right place to report this bug :)

To reproduce, guile -c '(format #t "~s\n" (integer-length 0))'
Expected result if correct: 1
Observed result: 0

The following is to support the opinion that 1 is the correct result,
and to explore how integer "length" generalizes to other radixes and
also signed number writing other than sign-magnitude.

Feel free to skip the following if of no interest :)

The tl;dr is:
    (integer-length 0) should agree with:
    (string-length (number->string 0 2)) =-> 1
        -- and not:   (integer-length 0) =-> 0

The integer length in bits (short for binary digits :)
is the number digits required to write the integer value
in conventional big-endian digit order, signifying coefficients
of successive powers of the radix used.

This applies irrespective of the radix. Thus "11" in decimal is
  "1*10^1 + 1*10^0"
or hex is
  "11*16^0"
or binary is
  "1*2^1 + 1*2^0"

So, the crux of the argument is that it takes one digit to write
either 1 or 0:
--8<---------------cut here---------------start------------->8---
Inputs: 1 (radix 10, decimal value unsigned 1) (output radix 2)
  Number as radix-2 glyph{0..1} string (unsigned)
  "1"
  Number as glyphs representing coefficient values of radix polynomial for number value:
  ("1")
  (1) -- corresponding coefficient values
  Number as polynomial expression:
  "1*2^0"
  (1) -- corresponding term values
  1 -- sum of term values
  The following should be equal to guile's (integer-length 1):
  1 integer-digit (radix 2)
--8<---------------cut here---------------end--------------->8---

--8<---------------cut here---------------start------------->8---
Inputs: 0 (radix 10, decimal value unsigned 0) (output radix 2)
  Number as radix-2 glyph{0..1} string (unsigned)
  "0"
  Number as glyphs representing coefficient values of radix polynomial for number value:
  ("0")
  (0) -- corresponding coefficient values
  Number as polynomial expression:
  "0*2^0"
  (0) -- corresponding term values
  0 -- sum of term values
  The following should be equal to guile's (integer-length 0):
  1 integer-digit (radix 2)
--8<---------------cut here---------------end--------------->8---

BTW, this works for signed numbers as well, if you use a complement
representation making the sign digit 0 for positive and radix-1 for
negative (thus 0 and 1 for radix 2, and e.g. 0 and f for radix 16).

Decimal is just another radix:

Inputs: -11 (radix 10, decimal value minus 11) (output radix 10)
  Number as radix-10 glyph{0..9} string (radix-complement -sign prefix)
  "989" (complement notation)
   ^--(note that 0 and "9" (radix10 -1) are sign digits for 0 and -1 coefficient values in the polynomial)
  Number as glyphs representing coefficient values of radix polynomial for number value:
  ("-1" "8" "9")
  (-1 8 9) -- corresponding coefficient values
  Number as polynomial expression:
  "-1*10^2 + 8*10^1 + 9*10^0"
  (-100 80 9) -- corresponding term values
  -11 -- sum of term values
  Tip: for guile integer-length, enter unsigned value with output radix 2
  3 integer-digits (radix 10)

The extreme for this version is radix 36:

Inputs: -11 (radix 36, decimal value minus 37) (output radix 36)
  Number as radix-36 glyph{0..z} string (radix-complement -sign prefix)
  "zyz" (complement notation)
   ^--(note that 0 and "z" (radix36 -1) are sign digits for 0 and -1 coefficient values in the polynomial)
  Number as glyphs representing coefficient values of radix polynomial for number value:
  ("-1" "y" "z")
  (-1 34 35) -- corresponding coefficient values
  Number as polynomial expression:
  "-1*36^2 + 34*36^1 + 35*36^0"
  (-1296 1224 35) -- corresponding term values
  -37 -- sum of term values
  Tip: for guile integer-length, enter unsigned value with output radix 2
  3 integer-digits (radix 36)

I got a little carried away exploring the complement notation, and wrote
a thing to explain the meanings. Please copy snip to int2poly and chmod 755 it.
Then run once without args for usage help.

I hope it will convince you that guile (integer-length 0) should be 1 ;-)

--8<---------------cut here---------------start------------->8---
#!/usr/bin/env -S guile -e main -s
!#
;; run without arguments for usage, or read below
;; int2poly-0.1.0 -- 2020-04-21 

(use-modules (ice-9 format)
	     (ice-9 regex))

(define self (basename (car (command-line))))
(define verbose #f)

(define (usage)
  (begin
    (let*((selfxxx (basename (car (command-line)))))
      (begin
	(format (current-error-port)
		"Usage:
        ~a  [-v ] | NUMSTR  [out-radix] [inp-radix]
        where *-radix are entered in decimal, and
        out-radix defaults to 2 and inp-radix defaults to 10,
        but may set independently to 2..36 to demo generality.

        -v for verbose output explanations

        NUMSTR will be written in radix digits representing
        polynomial coefficients, which is presented in series terms
        and evaluated back to the original number.

        The NUMSTR character set is the same as for (number->string radix)
        but could be any chosen set of distinct glyphs for values {0..<radix -1>}.

        guile integer-length can be considered a special case of
        coefficient count for radix 2, which is  printed in the last
        line of output as \"N integer-digits (radix N)\n"
		self ))
      (if (= (integer-length 0) 0)
	  (begin
	  (format #t "\nGuile[1] bug:
    (integer-length 0) should agree with:
    (string-length (number->string 0 2)) =-> ~s
        -- and not:   (integer-length 0) =-> ~s
    And it should agree with integer-digits for ~a 1 and ~a 0
    Try ~a 0, and note that it is 1 for any radix 2-36
    and numstr is 10 for ~a radix radix also for any radix ;-)\n\n"
		  (string-length (number->string 0 2))
		  (integer-length 0)
		  self self self self)
	  (display "[1] ----\n")
	  (system "guile -v")
	  (display "----\n ")
	  )))))

(define (main argl)
  (begin
    (set! argl (cdr argl))
    (if (not (pair? argl)) (begin (usage) (exit)))
    (if (string=? "-v" (car argl)) (begin (set! verbose #t) (set! argl (cdr argl))))
    (if (not (pair? argl)) (begin (usage) (exit)))
    (let*((matstr (string-match "[0-9a-z]+" (string-join argl " "))) ;; for <prefix><substring><suffix>
	  (sgnstr (match:prefix matstr))    ;; [<sign>]
	  (absstr (match:substring matstr)) ;;         <inpnum> [<out-radix>] [<in-radix>] 

	  (matst2 (string-match "[0-9]+" (match:suffix matstr))) ;; demo radix (spec in decimal)  [<out-radix>] [<inp-radix>]
          (radix (if matst2 (string->number (match:substring matst2)) 2)) ;; default demo radix is 2

	  (matst3 (if matst2 (string-match "[0-9]+" (match:suffix matst2)) #f)) ;;                                [<inp-radix>]
	  (iradix (if matst3 (string->number (match:substring matst3)) 10)) ;; default input radix 10

	  (absnum (string->number absstr iradix)) ;; abs math value of input
	  (abswid (string-length (number->string absnum radix)))
	  (radixp (integer-expt radix (+ 1 abswid))) ;; 2nd bit above msb of absnum
	  (usenum (if (string=? "-" sgnstr) (- radixp absnum) (+ radixp absnum))) ;; 10abs or 10000-abs
	                                                                          ;;          _1xyx
	                                                                          ;;      or  10000 if abs=0
	  (numstr1 (number->string usenum radix))
	  (numoff (if (string=? "" sgnstr)
		      2
		      (- (string-length numstr1) (+ 1 abswid))))

	  (numstr (substring numstr1 numoff))
	  (coeffs (map match:substring  (list-matches "(.)" numstr)))
	  (coeffs (if (string=? "" sgnstr)
		      coeffs
		      (begin
			(if (char=? (string-ref numstr 0)
				    (string-ref (number->string (- radix 1) radix) 0))
			    (cons "-1" (cdr coeffs))
			    coeffs))))
	  (coeffv (map (lambda (s) (string->number s radix)) coeffs))
	  (ncoeff (length coeffs))
	  (terms (string-join (reverse (map (lambda (coeff power)
				 (begin (format #f "~d*~d^~d" coeff radix power))) (reverse coeffv) (iota ncoeff))) " + "))
	  (termv (reverse (map (lambda (coeff power)
				 (begin (* coeff (integer-expt radix power)))) (reverse coeffv) (iota ncoeff))))
	  (polyv (apply + termv))

	  (signword (begin (cond
			    ((string=? "" sgnstr) "unsigned")
			    ((string=? "+" sgnstr) "plus")
			    ((string=? "-" sgnstr) "minus")
			    (else (throw 'int2poly "bad sign:" sgnstr)))))
	  (sgnnote (begin (cond
			    ((string=? "" sgnstr) "(unsigned)")
			    ((string=? "+" sgnstr) "(radix-complement +sign prefix)")
			    ((string=? "-" sgnstr) "(radix-complement -sign prefix)")
			    (else (throw 'int2poly "bad sign:" sgnstr)))))
	  )
      (begin
	(format #t "Inputs: ~a~a (radix ~s, decimal value ~a ~s) (output radix ~s)\n" sgnstr absstr iradix signword absnum radix)
        (if verbose (format #t "  Number as radix-~s glyph{~a..~a} string ~a\n"
	 		    radix  (number->string 0 radix) (number->string (- radix 1) radix)  sgnnote))
	(format #t "  ~s~a\n" numstr (if (string=? "" sgnstr) "" " (complement notation)"))
	(if (and verbose (not (string=? sgnstr "")))
	    (format #t "   ^--(note that 0 and ~s (radix~a -1) are sign digits for 0 and -1 coefficient values in the polynomial)\n"
							     (number->string (- radix 1) radix) radix))
	(format #t "~a  ~s\n" (if verbose "  Number as glyphs representing coefficient values of radix polynomial for number value:\n" "") coeffs)
	(format #t "  ~s~a\n" coeffv (if verbose  " -- corresponding coefficient values" ""))
	(format #t "~a  ~s\n" (if verbose "  Number as polynomial expression:\n" "") terms)
	(format #t "  ~s~a\n" termv (if verbose " -- corresponding term values" ""))
	(format #t "  ~s~a\n" polyv (if verbose " -- sum of term values" ""))
	(if verbose
	    (if (and (= radix 2) (string=? sgnstr ""))
		(format #t "  The following should be equal to guile's (integer-length ~s):\n" absnum)
		(format #t "  Tip: for guile integer-length, enter unsigned value with output radix 2\n")))
	(format #t "  ~s integer-digit~a (radix ~a)\n" ncoeff (if (> ncoeff 1) "s" "") radix))
      )))
--8<---------------cut here---------------end--------------->8---

-- 
Regards,
Bengt Richter



------------=_1588097343-15286-3--


Message received at fakecontrol@fakecontrolmessage:


Received: (at fakecontrol) by fakecontrolmessage;
To: internal_control <at> debbugs.gnu.org
From: Debbugs Internal Request <help-debbugs@HIDDEN>
Subject: Internal Control
Message-Id: Did not alter fixed versions and reopened.
Date: Tue, 28 Apr 2020 18:38:01 +0000
User-Agent: Fakemail v42.6.9

# This is a fake control message.
#
# The action:
# Did not alter fixed versions and reopened.
thanks
# This fakemail brought to you by your local debbugs
# administrator


Message sent to bug-guile@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#40744: guile-2.2.4 (integer-length 0) erroneously returns 0, not 1
Resent-From: =?UTF-8?Q?Bj=C3=B6rn_?= =?UTF-8?Q?H=C3=B6fling?= <bjoern.hoefling@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-guile@HIDDEN
Resent-Date: Tue, 28 Apr 2020 18:42:01 +0000
Resent-Message-ID: <handler.40744.B40744.158809927318753 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 40744
X-GNU-PR-Package: guile
X-GNU-PR-Keywords: 
To: Bengt Richter <bokr@HIDDEN>
Cc: 40744 <at> debbugs.gnu.org
Received: via spool by 40744-submit <at> debbugs.gnu.org id=B40744.158809927318753
          (code B ref 40744); Tue, 28 Apr 2020 18:42:01 +0000
Received: (at 40744) by debbugs.gnu.org; 28 Apr 2020 18:41:13 +0000
Received: from localhost ([127.0.0.1]:41454 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1jTVAP-0004sP-AE
	for submit <at> debbugs.gnu.org; Tue, 28 Apr 2020 14:41:13 -0400
Received: from m4s11.vlinux.de ([83.151.27.109]:59026 helo=bjoernhoefling.de)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <bjoern.hoefling@HIDDEN>)
 id 1jTVAO-0004sH-0I
 for 40744 <at> debbugs.gnu.org; Tue, 28 Apr 2020 14:41:12 -0400
Received: from alma-ubu (p508ACA3F.dip0.t-ipconnect.de [80.138.202.63])
 (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
 (No client certificate requested)
 by bjoernhoefling.de (Postfix) with ESMTPSA id 5B9353F861;
 Tue, 28 Apr 2020 20:41:11 +0200 (CEST)
Date: Tue, 28 Apr 2020 20:41:10 +0200
From: =?UTF-8?Q?Bj=C3=B6rn_?= =?UTF-8?Q?H=C3=B6fling?= <bjoern.hoefling@HIDDEN>
Message-ID: <20200428204110.50e47ad0@alma-ubu>
In-Reply-To: <20200428200810.7d619d27@alma-ubu>
References: <20200421130344.GA9369@LionPure> <20200425213350.GA10462@LionPure>
 <20200428200810.7d619d27@alma-ubu>
X-Mailer: Claws Mail 3.16.0 (GTK+ 2.24.32; x86_64-pc-linux-gnu)
MIME-Version: 1.0
Content-Type: multipart/signed; micalg=pgp-sha1;
 boundary="Sig_/xhGgDPQdWEnS3g8=Ue2bxHh"; protocol="application/pgp-signature"
X-Spam-Score: 0.4 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

--Sig_/xhGgDPQdWEnS3g8=Ue2bxHh
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

On Tue, 28 Apr 2020 20:08:10 +0200
Bj=C3=B6rn H=C3=B6fling <bjoern.hoefling@HIDDEN> wrote:


> Bugreport was re-opened under the guile package here:
>=20
> https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D40855
>=20
> Closing this one.

Oh, I didn't realize they were merged. So, I reopened them again :-)

Bj=C3=B6rn

--Sig_/xhGgDPQdWEnS3g8=Ue2bxHh
Content-Type: application/pgp-signature
Content-Description: OpenPGP digital signature

-----BEGIN PGP SIGNATURE-----

iF0EARECAB0WIQQiGUP0np8nb5SZM4K/KGy2WT5f/QUCXqh4xgAKCRC/KGy2WT5f
/VrSAKCFtLo+YPVEcSR0r56/E89MH63n/wCgr/leaDIv1YcTerSkP6mDQ/vtloA=
=P55J
-----END PGP SIGNATURE-----

--Sig_/xhGgDPQdWEnS3g8=Ue2bxHh--




Message sent to bug-guile@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#40744: guile-2.2.4 (integer-length 0) erroneously returns 0, not 1
Resent-From: Rob Browning <rlb@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-guile@HIDDEN
Resent-Date: Fri, 16 Jul 2021 03:02:01 +0000
Resent-Message-ID: <handler.40744.B40744.162640449530957 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 40744
X-GNU-PR-Package: guile
X-GNU-PR-Keywords: 
To: =?UTF-8?Q?Bj=C3=B6rn_?= =?UTF-8?Q?H=C3=B6fling?= <bjoern.hoefling@HIDDEN>, Bengt Richter <bokr@HIDDEN>
Cc: 40744 <at> debbugs.gnu.org
Received: via spool by 40744-submit <at> debbugs.gnu.org id=B40744.162640449530957
          (code B ref 40744); Fri, 16 Jul 2021 03:02:01 +0000
Received: (at 40744) by debbugs.gnu.org; 16 Jul 2021 03:01:35 +0000
Received: from localhost ([127.0.0.1]:50217 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1m4E6Z-00083F-D5
	for submit <at> debbugs.gnu.org; Thu, 15 Jul 2021 23:01:35 -0400
Received: from defaultvalue.org ([45.33.119.55]:53102 ident=postfix)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <rlb@HIDDEN>) id 1m4E6X-000837-Ka
 for 40744 <at> debbugs.gnu.org; Thu, 15 Jul 2021 23:01:34 -0400
Received: from trouble.defaultvalue.org (localhost [127.0.0.1])
 (Authenticated sender: rlb@HIDDEN)
 by defaultvalue.org (Postfix) with ESMTPSA id B56AD202FD;
 Thu, 15 Jul 2021 22:01:32 -0500 (CDT)
Received: by trouble.defaultvalue.org (Postfix, from userid 1000)
 id 4BF8B14E48B; Thu, 15 Jul 2021 22:01:32 -0500 (CDT)
From: Rob Browning <rlb@HIDDEN>
In-Reply-To: <20200428204110.50e47ad0@alma-ubu>
References: <20200421130344.GA9369@LionPure>
 <20200425213350.GA10462@LionPure> <20200428200810.7d619d27@alma-ubu>
 <20200428204110.50e47ad0@alma-ubu>
Date: Thu, 15 Jul 2021 22:01:32 -0500
Message-ID: <87pmvjarn7.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: -0.0 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)


Hmm, the zero result appears to be intentional, i.e. it's mentioned in
the examples here:

  https://www.gnu.org/software/guile/manual/guile.html#Arithmetic

and is also specified by Chez Scheme and SRFI-60:

  https://www.scheme.com/csug8/numeric.html
  https://srfi.schemers.org/srfi-60/srfi-60.html

-- 
Rob Browning
rlb @defaultvalue.org and @debian.org
GPG as of 2011-07-10 E6A9 DA3C C9FD 1FF8 C676 D2C4 C0F0 39E9 ED1B 597A
GPG as of 2002-11-03 14DD 432F AE39 534D B592 F9A0 25C8 D377 8C7E 73A4




Message sent to bug-guile@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#40744: guile-2.2.4 (integer-length 0) erroneously returns 0,  not 1
Resent-From: Bengt Richter <bokr@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-guile@HIDDEN
Resent-Date: Sat, 24 Jul 2021 17:13:02 +0000
Resent-Message-ID: <handler.40744.B40744.162714675327665 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 40744
X-GNU-PR-Package: guile
X-GNU-PR-Keywords: 
To: Rob Browning <rlb@HIDDEN>
Cc: =?UTF-8?Q?Bj=C3=B6rn_?= =?UTF-8?Q?H=C3=B6fling?= <bjoern.hoefling@HIDDEN>, 40744 <at> debbugs.gnu.org
Reply-To: Bengt Richter <bokr@HIDDEN>
Received: via spool by 40744-submit <at> debbugs.gnu.org id=B40744.162714675327665
          (code B ref 40744); Sat, 24 Jul 2021 17:13:02 +0000
Received: (at 40744) by debbugs.gnu.org; 24 Jul 2021 17:12:33 +0000
Received: from localhost ([127.0.0.1]:46859 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1m7LCS-0007C9-RO
	for submit <at> debbugs.gnu.org; Sat, 24 Jul 2021 13:12:33 -0400
Received: from imta-37.everyone.net ([216.200.145.37]:40896
 helo=imta-38.everyone.net)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <bokr@HIDDEN>) id 1m7LCO-0007Bw-K1
 for 40744 <at> debbugs.gnu.org; Sat, 24 Jul 2021 13:12:32 -0400
Received: from pps.filterd (omta004.sj2.proofpoint.com [127.0.0.1])
 by imta-38.everyone.net (8.16.0.43/8.16.0.43) with SMTP id 16OH2nxC011413;
 Sat, 24 Jul 2021 10:12:21 -0700
X-Eon-Originating-Account: GbEDZzLWbb_YO25mu4qgqkK_ND2YCn4vH_chHbP7IFY
X-Eon-Dm: m0116787.ppops.net
Received: by m0116787.mta.everyone.net (EON-AUTHRELAY2 - 53b921d1)
 id m0116787.60d3a85b.1d137c; Sat, 24 Jul 2021 10:12:19 -0700
X-Eon-Sig: AQMHrIJg/EnzWa7ezAIAAAAD,55694c33662f9e3165e2bde066b10c20
X-Eip: ouclBmbJ_1VdFqkrorB0RvZY7VH8eCtaMvcLX9k5aGI
Date: Sat, 24 Jul 2021 19:12:08 +0200
From: Bengt Richter <bokr@HIDDEN>
Message-ID: <20210724171208.GA11765@LionPure>
References: <20200421130344.GA9369@LionPure> <20200425213350.GA10462@LionPure>
 <20200428200810.7d619d27@alma-ubu>
 <20200428204110.50e47ad0@alma-ubu>
 <87pmvjarn7.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
In-Reply-To: <87pmvjarn7.fsf@HIDDEN>
User-Agent: Mutt/1.10.1 (2018-07-13)
X-Proofpoint-ORIG-GUID: sZKi0eG9RWc1gRynKj02cuD3oQ57jsam
X-Proofpoint-GUID: sZKi0eG9RWc1gRynKj02cuD3oQ57jsam
X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391, 18.0.790
 definitions=2021-07-24_11:2021-07-23,
 2021-07-24 signatures=0
X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0
 priorityscore=1501
 clxscore=1034 suspectscore=0 adultscore=0 spamscore=0 malwarescore=0
 impostorscore=0 mlxscore=0 mlxlogscore=999 phishscore=0 lowpriorityscore=0
 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000
 definitions=main-2107240104
X-Spam-Score: 0.2 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.8 (/)

Oops, forgot to reply-all -- sorry about the dup, Rob ;/

On +2021-07-15 22:01:32 -0500, Rob Browning wrote:
> 
> Hmm, the zero result appears to be intentional, i.e. it's mentioned in
> the examples here:
> 
>   https://www.gnu.org/software/guile/manual/guile.html#Arithmetic
> 
> and is also specified by Chez Scheme and SRFI-60:
> 
>   https://www.scheme.com/csug8/numeric.html
>   https://srfi.schemers.org/srfi-60/srfi-60.html
> 
> -- 
> Rob Browning
> rlb @defaultvalue.org and @debian.org
> GPG as of 2011-07-10 E6A9 DA3C C9FD 1FF8 C676 D2C4 C0F0 39E9 ED1B 597A
> GPG as of 2002-11-03 14DD 432F AE39 534D B592 F9A0 25C8 D377 8C7E 73A4

I tried to make a pitch for (integer-length 0) =-> 1 in
[1]    https://lists.gnu.org/archive/html/bug-guile/2020-04/msg00027.html
though I now think integer-length is a useful measure of mathematical
integervalues that can be generalized to any rational numbers and
complex numbers with rational real and imaginary parts.

Also their printed representations can have any rational radix other
than 1 and negative generalized integer-lengths can be meaningful for
length of 1/x vs x (which brings in the zero issue).

For the "integer-length" I compute in [1], I would now suggest an alternate
name: integer-digits -- the number of concrete digit-value representations
it take to represent the polynomial coefficient values in the mathematical
polynomial series.

I should update [1] to reflect what I am saying here to remove complaints
about integer-length 0 etc and talk about integer-digits (or maybe
rational-digits or even numeric-digits?)

I think scheme's integer-length basically solves for minimum L in
in a mapping of rational numbers (limited to integers in its case)
for + and minus like
[0..2**L) for positive and [-2**L..0) for negative.

Those half-open sets correspond, so we can just use the absolute value
like abslen here:
--8<---------------cut here---------------start------------->8---
#!/usr/bin/env -S guile --no-auto-compile -e main -s
!#
(use-modules (ice-9 format))

(define (abslen absint)
  (begin
    (let*((absval absint)
    	  (lm (lambda (aval)
    		(begin
    		  (let inner ((n 0) (av aval))
    		    (begin
    	              (if
    	               (< (integer-expt 2 n) av) 
    	               (inner (+ 1 n) av)
    	               n)))))))
	(lm absval))))

(define (main args)
  (begin
    (or
     (false-if-exception 
      (begin
	(display (abslen (abs (string->number (cadr args)))))
	(newline)))
     (begin
       (format #t "\nUsage: ~a NUM -- where NUM is [+ - ] POSITIVE_INTEGER\n" (car args)))
     (newline))))
--8<---------------cut here---------------end--------------->8---

You might want to call the above something other than integer-length,
but it should compute the same result (modulo very limited testing :).

As mentioned in Tom's reply to [1], zero makes for a special problem
in the general mathematical case, where I think you have to special-case
which set of points it should belong to.

In the general case numbers map into half-open annuli in the complex plane,
where inside and outside the unit circle corresponds to x and 1/x, and 1/0
has to be special-cased. The annulus edge circles are at powers of a rational
base, 2 in the binary case, but 4/3 can work. Just not irrationals.
(Maybe as named unit values though?)

Conventional signed number mappings split an annulus in two to map them,
with positives < the splitting circle and negatives >=

Something analogous to abslen can be done to find the power of the base
that will be the diameter of a circle containing (> not >=) both parts
of the split annulus. I haven't done it yet :)

Complex numbers have both cartesian and polar representations, so that
brings in interesting stuff too. The negative of a complex number as
a point in the complex plane is diametrically opposite the origin, but
zero has no direction to an opposite of itself :)
Defining -0 to be 0 has consequences. (Note that fp hardware does
represent -0 :)

You might find it amusing to play with the scheme program
included in [1] (after you inspect it -- no warranties :).

-- 
Regards,
Bengt Richter
PS. Shouldn't euclidean-quotient always produce an exact integer?
(Inexactness if any can be carried by the remainder)





Last modified: Sat, 24 Jul 2021 17:15:01 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.