From: "Panicz Maciej Godek" <godek.maciek@gmail.com>
To: guile-user@gnu.org
Subject: How to stay in fixnum range?
Date: Mon, 19 Jan 2009 22:02:35 +0100 [thread overview]
Message-ID: <1eb53f5d0901191302tecf055bte1e37ad167858b9c@mail.gmail.com> (raw)
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.
next reply other threads:[~2009-01-19 21:02 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-01-19 21:02 Panicz Maciej Godek [this message]
2009-01-21 9:00 ` How to stay in fixnum range? Neil Jerram
2009-01-21 9:54 ` Panicz Maciej Godek
2009-01-21 16:28 ` Ludovic Courtès
2009-01-21 17:52 ` Neil Jerram
2009-01-21 15:00 ` Andy Wingo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1eb53f5d0901191302tecf055bte1e37ad167858b9c@mail.gmail.com \
--to=godek.maciek@gmail.com \
--cc=guile-user@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).