unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* How to stay in fixnum range?
@ 2009-01-19 21:02 Panicz Maciej Godek
  2009-01-21  9:00 ` Neil Jerram
  2009-01-21 15:00 ` Andy Wingo
  0 siblings, 2 replies; 6+ messages in thread
From: Panicz Maciej Godek @ 2009-01-19 21:02 UTC (permalink / raw)
  To: guile-user

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.




^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2009-01-21 17:52 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-01-19 21:02 How to stay in fixnum range? Panicz Maciej Godek
2009-01-21  9:00 ` 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

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).