From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Ramakrishnan Muthukrishnan Newsgroups: gmane.lisp.guile.devel Subject: Re: fix for expt bug Date: Mon, 1 Nov 2010 23:53:46 +0530 Message-ID: References: <8762whnc4d.fsf@yeeloong.netris.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary=001485f89a3cdf4963049401e903 X-Trace: dough.gmane.org 1288635859 5079 80.91.229.12 (1 Nov 2010 18:24:19 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 1 Nov 2010 18:24:19 +0000 (UTC) To: guile-devel Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Mon Nov 01 19:24:15 2010 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1PCz3G-0001rk-7Q for guile-devel@m.gmane.org; Mon, 01 Nov 2010 19:24:14 +0100 Original-Received: from localhost ([127.0.0.1]:35100 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PCz3F-0003zW-IM for guile-devel@m.gmane.org; Mon, 01 Nov 2010 14:24:13 -0400 Original-Received: from [140.186.70.92] (port=43265 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PCz3B-0003ua-4X for guile-devel@gnu.org; Mon, 01 Nov 2010 14:24:10 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PCz39-0002YT-Ke for guile-devel@gnu.org; Mon, 01 Nov 2010 14:24:08 -0400 Original-Received: from mail-gx0-f169.google.com ([209.85.161.169]:58440) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PCz39-0002YH-HL for guile-devel@gnu.org; Mon, 01 Nov 2010 14:24:07 -0400 Original-Received: by gxk2 with SMTP id 2so2373865gxk.0 for ; Mon, 01 Nov 2010 11:24:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:mime-version:received:in-reply-to :references:from:date:message-id:subject:to:content-type; bh=xgo6q1odpLkstYuhRAqNb8detVxAajLVx5W7Vldw9ro=; b=a5S2SJDOhB3I9lilY1ZyqhVBWjN9DETO4kYVnov6CF4RVAQq26eB6DTh7hVstYlnmv mablV1lc2iVB0JIYvsD5YAsBIl8BsUHRaXeNbmoZjRACJ8Nkz17yWn7HbIDFC83r6W5v gHDZszMWgWdrXhA0ViFtfpHv6bc2tfyNgVA0o= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; b=DL188NGyn3AB0j2dk3DHUZXjcGfIx3kdCTGT1jQfiFUyIIsRBWk2rge7F5b39Nsrt8 jCcXHj0AzS9vYGGVPW+BWmuzTcuxGc5d0Rdmfh6hDIsc1n7Am+T6jANdoR0Cm5Znn0tl 9qsQOv8YO5RXTmwWSVtuwhnsFtv8QR7QPGG80= Original-Received: by 10.229.238.197 with SMTP id kt5mr15555959qcb.25.1288635846445; Mon, 01 Nov 2010 11:24:06 -0700 (PDT) Original-Received: by 10.229.40.147 with HTTP; Mon, 1 Nov 2010 11:23:46 -0700 (PDT) In-Reply-To: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:11097 Archived-At: --001485f89a3cdf4963049401e903 Content-Type: text/plain; charset=UTF-8 I reworked the patch a bit as per Mark's comments. It takes care of the sign part and handles integer power values properly. It also fixes another bug with the current expt implementation where base is an integer and the power value is not (eg: (expt 2 2.0) gives an error in the current git master. The patch fixes this too.) Also adds some test cases. Please review. Thanks Ramakrishnan --001485f89a3cdf4963049401e903 Content-Type: text/x-patch; charset=US-ASCII; name="expt-fix.patch" Content-Disposition: attachment; filename="expt-fix.patch" Content-Transfer-Encoding: base64 X-Attachment-Id: f_gfzoa48u0 RnJvbSAwMjViZGU3OGQ0YzE5OWRlZTFkMjg1N2U5MTNkNjljZTRkN2MyZTU5IE1vbiBTZXAgMTcg MDA6MDA6MDAgMjAwMQpGcm9tOiBSYW1ha3Jpc2huYW4gTXV0aHVrcmlzaG5hbiA8dnUzcmRkQGdt YWlsLmNvbT4KRGF0ZTogU3VuLCAzMSBPY3QgMjAxMCAyMzoyMjo1MiArMDUzMApTdWJqZWN0OiBb UEFUQ0hdIEZpeCBmb3IgYnVnICMzMTQ2NC4gZXhwdCBuZWVkcyB0byB0cmVhdCBuZWdhdGl2ZSBi YXNlcyBzcGVjaWFsbHkuCgoqIGxpYmd1aWxlL251bWJlcnMuYzogSWYgYmFzZSBpcyBuZWdhdGl2 ZSwgZXhwdCBuZWVkcyB0byBmaW5kCiAgLXhebiA9ICgtMV5uKSAqICh8eHxebikuIFdlIGZpbmQg eF5uIGFuZCB0aGVuIGlmIG4gaXMgb2RkLCB3ZQogIGFsc28gbXVsdGlwbHkgdGhlIHJlc3VsdCB3 aXRoIC0xLiBUaGVzZSBjaGFuZ2VzIGFwcGx5IG9ubHkgZm9yCiAgY2FzZXMgd2hlcmUgbiBpcyBh biBpbnRlZ2VyLgoKKiB0ZXN0LXN1aXRlL3Rlc3RzL251bWJlcnMudGVzdDogVHdvIG5ldyB0ZXN0 IGNhc2VzIGZvciBleHB0LiBGb3IKICBjYXNlcyB3aGVyZSB0aGUgYmFzZSBpcyBuZWdhdGl2ZSBh bmQgdGhlIHBvd2VyIHRvIGJlIHJhaXNlZCBpcwogIG5vdCBhbiBpbnRlZ2VyLCB0aGUgcmVzdWx0 IHNob3V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sZSAoeCksIHNjbV90b19kb3VibGUgKHkpKSk7CiAgICAgfQor ICBlbHNlIGlmIChzY21faXNfcmVhbCAoeCkgJiYKKyAgICAgICAgICAgc2NtX2lzX3JlYWwgKHkp ICYmCisgICAgICAgICAgIChzY21fdG9fZG91YmxlICh4KSA8IDApICYmCisgICAgICAgICAgICFT Q01fRlJBQ1RJT05QICh5KSkKKyAgICB7CisgICAgICBTQ00geF9hYnMsIHJlc3VsdDsKKworICAg ICAgeF9hYnMgPSBzY21fYWJzICh4KTsKKyAgICAgIHJlc3VsdCA9IHNjbV9mcm9tX2RvdWJsZSAo cG93IChzY21fdG9fZG91YmxlICh4X2FicyksIHNjbV90b19kb3VibGUgKHkpKSk7CisKKyAgICAg IGlmIChzY21faXNfdHJ1ZSAoc2NtX2VxdWFsX3AgKHksIHNjbV9mbG9vciAoeSkpKSAmJgorICAg ICAgICAgIHNjbV9pc190cnVlIChzY21fb2RkX3AgKHkpKSkKKyAgICAgICAgcmV0dXJuIHNjbV9w cm9kdWN0IChzY21fZnJvbV9kb3VibGUgKC0xLjApLCByZXN1bHQpOworICAgICAgZWxzZQorICAg ICAgICByZXR1cm4gcmVzdWx0OworICAgIH0KICAgZWxzZQogICAgIHJldHVybiBzY21fZXhwIChz Y21fcHJvZHVjdCAoc2NtX2xvZyAoeCksIHkpKTsKIH0KZGlmZiAtLWdpdCBhL3Rlc3Qtc3VpdGUv dGVzdHMvbnVtYmVycy50ZXN0IGIvdGVzdC1zdWl0ZS90ZXN0cy9udW1iZXJzLnRlc3QKaW5kZXgg M2MzZTE0Zi4uNjM3NDQ5ZiAxMDA2NDQKLS0tIGEvdGVzdC1zdWl0ZS90ZXN0cy9udW1iZXJzLnRl c3QKKysrIGIvdGVzdC1zdWl0ZS90ZXN0cy9udW1iZXJzLnRlc3QKQEAgLTI4OTIsNyArMjg5Miwy MCBAQAogICAocGFzcy1pZiAiKD0gMSAoZXhwdCAwIDApKSIgKD0gMSAoZXhwdCAwIDApKSkKICAg KH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