From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Panicz Maciej Godek" Newsgroups: gmane.lisp.guile.user Subject: How to stay in fixnum range? Date: Mon, 19 Jan 2009 22:02:35 +0100 Message-ID: <1eb53f5d0901191302tecf055bte1e37ad167858b9c@mail.gmail.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1232399008 21051 80.91.229.12 (19 Jan 2009 21:03:28 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 19 Jan 2009 21:03:28 +0000 (UTC) To: guile-user@gnu.org Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Mon Jan 19 22:04:41 2009 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1LP1IO-0001Jv-7C for guile-user@m.gmane.org; Mon, 19 Jan 2009 22:04:32 +0100 Original-Received: from localhost ([127.0.0.1]:39164 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LP1H6-0005Ns-Tr for guile-user@m.gmane.org; Mon, 19 Jan 2009 16:03:13 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LP1GZ-0005N1-9Q for guile-user@gnu.org; Mon, 19 Jan 2009 16:02:39 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LP1GY-0005Mk-J1 for guile-user@gnu.org; Mon, 19 Jan 2009 16:02:38 -0500 Original-Received: from [199.232.76.173] (port=48121 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LP1GY-0005Me-BF for guile-user@gnu.org; Mon, 19 Jan 2009 16:02:38 -0500 Original-Received: from mail-ew0-f20.google.com ([209.85.219.20]:41348) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1LP1GX-0000N4-Q7 for guile-user@gnu.org; Mon, 19 Jan 2009 16:02:37 -0500 Original-Received: by ewy13 with SMTP id 13so720246ewy.18 for ; Mon, 19 Jan 2009 13:02:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:mime-version:content-type:content-transfer-encoding :content-disposition; bh=2S/h7f3CtXocv2ugpn76E3tbTBl55+EPLkDtRtztPNI=; b=wGQEXlbGG7qsgJlEqdvJU302HTj7bdxFv1tP0BlpYRwjTMPC8U0kzrfK1XPVeofr6K +k7zri3yMAcXFXDN4HkuoxHNPsDNyYnNTVaXg3rVUSuuksPOv9MezSoHctCLQLR5atBR XcugxGA4crv2DD9ceRxZKAq6FN54xMBIm/fwE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:mime-version:content-type :content-transfer-encoding:content-disposition; b=hED2sUAf64a9mx0N6l3FdywBGUWBKybQUNx021d1OQ1f9xBaq13PsJTfckGZC8FkrQ hM7HLyZZfY+jfp36hvCZEBEVW+XxP7i5Lobfo1ml5E6FouHRZpIFZrC57m9fhn8Qf2ua Pd8+sS16DYceXgK3pKouU4P/8bqe0ey/XymHI= Original-Received: by 10.210.131.6 with SMTP id e6mr5633051ebd.77.1232398955870; Mon, 19 Jan 2009 13:02:35 -0800 (PST) Original-Received: by 10.210.113.5 with HTTP; Mon, 19 Jan 2009 13:02:35 -0800 (PST) Content-Disposition: inline X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.user:7067 Archived-At: Hi, I've been writing a program that has something to do with time processing. It uses the function get-internal-real-time to measure time in an infinite loop. I haven't been using running the program long enough to experience the range-exceeding phenomenon, but I thought of avoiding it in advance. The problem may appear when I add some number to the return value of get-internal-real-time -- what if, during addition, the scheme fixnum limit is exceeded and the variable becomes a bignum? What would be the most efficient solution? Should I compute the modulo of the sum by a fixnum (or its even divisor) to assure that the bignum limit is never exceeded? In low-level programming the case is simple, because the sum also falls beyond the range as well and no advanced bignum detection system is ever deployed. Is there a way to achieve the same effect in guile scheme? Regards M.