chicken-users
[Top][All Lists]
Advanced

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

Re: [Chicken-users] srfi-19 time, flonums and s11n


From: John Cowan
Subject: Re: [Chicken-users] srfi-19 time, flonums and s11n
Date: Mon, 3 Sep 2007 03:54:10 -0400
User-agent: Mutt/1.5.13 (2006-08-11)

Shawn Rutledge scripsit:

> Unix timestamps are annoying in Scheme because nowadays they take up
> most of a 32-bit unsigned int, so it won't fit in a fixnum.  If I want
> to pass a timeval from a C function to Scheme, I see that the
> unsigned-integer32 datatype gets converted to a flonum by default:

True, but that's not a problem except on oddball hardware.  Nowadays,
flonums are just as fast as ints on typical CPUs, sometimes faster.
And you don't have to worry about inaccuracies:  IEEE double floats
serve as perfectly good fixnums up through 2^53.  It's true that
Chicken boxes all floats, so you have some extra memory and
manipulation costs, but for timestamps accurate to only 1 second,
that shouldn't matter much either.

So go with the flonums; they're simpler.

-- 
All Gaul is divided into three parts: the part          John Cowan
that cooks with lard and goose fat, the part            http://ccil.org/~cowan
that cooks with olive oil, and the part that            address@hidden
cooks with butter. -- David Chessler




reply via email to

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