[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

How to stay in fixnum range?

From: Panicz Maciej Godek
Subject: How to stay in fixnum range?
Date: Mon, 19 Jan 2009 22:02:35 +0100

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?


reply via email to

[Prev in Thread] Current Thread [Next in Thread]