From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Newsgroups: gmane.lisp.guile.bugs Subject: bug#40855: integer-length 0 should be 1 Date: Sun, 26 Apr 2020 10:23:15 +0200 Message-ID: <20200426082315.GA3611@tuxteam.de> References: <20200425211540.GA10315@LionPure> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="cNdxnHkX5QqsyA0e" Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="23359"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mutt/1.5.21 (2010-09-15) To: 40855@debbugs.gnu.org Original-X-From: bug-guile-bounces+guile-bugs=m.gmane-mx.org@gnu.org Sun Apr 26 10:24:10 2020 Return-path: Envelope-to: guile-bugs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jSca9-0005xC-R5 for guile-bugs@m.gmane-mx.org; Sun, 26 Apr 2020 10:24:09 +0200 Original-Received: from localhost ([::1]:54784 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jSca8-0007aj-Rt for guile-bugs@m.gmane-mx.org; Sun, 26 Apr 2020 04:24:08 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:33006) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jSca3-0007aH-9Q for bug-guile@gnu.org; Sun, 26 Apr 2020 04:24:03 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jSca2-0006jC-IX for bug-guile@gnu.org; Sun, 26 Apr 2020 04:24:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:49270) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jSca2-0006j6-6n for bug-guile@gnu.org; Sun, 26 Apr 2020 04:24:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jSca2-0001Ok-2f for bug-guile@gnu.org; Sun, 26 Apr 2020 04:24:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Original-Sender: "Debbugs-submit" Resent-CC: bug-guile@gnu.org Resent-Date: Sun, 26 Apr 2020 08:24:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 40855 X-GNU-PR-Package: guile X-Debbugs-Original-To: bug-guile@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.15878894145322 (code B ref -1); Sun, 26 Apr 2020 08:24:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 26 Apr 2020 08:23:34 +0000 Original-Received: from localhost ([127.0.0.1]:60816 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jScZZ-0001Nl-U4 for submit@debbugs.gnu.org; Sun, 26 Apr 2020 04:23:34 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:39147) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jScZX-0001Nc-MJ for submit@debbugs.gnu.org; Sun, 26 Apr 2020 04:23:32 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:32950) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jScZW-0007UT-1o for bug-guile@gnu.org; Sun, 26 Apr 2020 04:23:30 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jScZS-0005BQ-0c for bug-guile@gnu.org; Sun, 26 Apr 2020 04:23:29 -0400 Original-Received: from mail.tuxteam.de ([5.199.139.25]:49246) by eggs.gnu.org with esmtps (TLS1.2:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.90_1) (envelope-from ) id 1jScZR-0004b7-3F for bug-guile@gnu.org; Sun, 26 Apr 2020 04:23:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tuxteam.de; s=mail; h=From:In-Reply-To:Content-Type:MIME-Version:References:Message-ID:Subject:To:Date; bh=YVl9KG+t8jdTnuXVBOhohlBazRYdA++lZT1vG0GaChA=; b=dujlECxGvVY+kZIT0FoyJid22t0WZ9yvgnnjsGFh5ifyprSTg2NkZe+WzcecTSo99vC+l2dCeC/cAvb/39MsS9QBCh/XO3jOGmOw2785PNSyqPUcLpocCu1sTYmyMpajThBZQyocCCBJxrkaPVehaTCD9+NivTGUEJgXNbxoc+txiNAnSOGBJ83c/h4Up7kAA655ebbHUroo/i9o8ZO+z5T0AHBVjFNn3dHjW87cf2XKNlIoccl783EaiSFdddbaadgjzwn4n7cW7DIiCeP79RVyFdOiLXkn1geG4PwXeF7XD5Sn0f6z2A1n1KwROynR07oMp2V+SzPP5Rzx0yPdxA==; Original-Received: from tomas by mail.tuxteam.de with local (Exim 4.80) (envelope-from ) id 1jScZH-0001H1-Fm for bug-guile@gnu.org; Sun, 26 Apr 2020 10:23:15 +0200 Content-Disposition: inline In-Reply-To: <20200425211540.GA10315@LionPure> Received-SPF: pass client-ip=5.199.139.25; envelope-from=tomas@tuxteam.de; helo=mail.tuxteam.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/04/26 04:23:15 X-ACL-Warn: Detected OS = Linux 3.1-3.10 [fuzzy] X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-Received-From: 209.51.188.43 X-BeenThere: bug-guile@gnu.org List-Id: "Bug reports for GUILE, GNU's Ubiquitous Extension Language" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guile-bounces+guile-bugs=m.gmane-mx.org@gnu.org Original-Sender: "bug-guile" Xref: news.gmane.io gmane.lisp.guile.bugs:9734 Archived-At: --cNdxnHkX5QqsyA0e Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sat, Apr 25, 2020 at 11:15:40PM +0200, Bengt Richter wrote: > I'm hoping this is the right place to report this bug :) >=20 > To reproduce, guile -c '(format #t "~s\n" (integer-length 0))' > Expected result if correct: 1 > Observed result: 0 >=20 > 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. Hm. This is a tough one. The problem is that there are several possible extensions to zero, and no one is quite right. For example, one could interpret (integer-length n) as one plus the base-two logarithm of n (well, its integer part). Or, in mathy jargon, 1 + floor(log2 n). In this case, the integer-length of zero would be minus infinity! And for negative n, we'd be in hot water (or in complex analysis or something :) Thus, the simple definition given in the doc "For positive N this is how many bits to the most significant one bit" looks like a wise choice to me -- and this leads to a value of 0 for 0 (or some infinity, if you keep searching for the one bit you'll never find, if you insist to find an one. Cheers -- tom=C3=A1s --cNdxnHkX5QqsyA0e Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) iEYEARECAAYFAl6lRPMACgkQBcgs9XrR2kZzrQCeKg8s0p9kgyf9DLO6FQmYHyTu CBkAn198RkVkHMnox9y8obE4AXZJtUBr =arWN -----END PGP SIGNATURE----- --cNdxnHkX5QqsyA0e--