[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Chicken-users] current-time on 32-bit hardware
From: |
Nicolas Pelletier |
Subject: |
Re: [Chicken-users] current-time on 32-bit hardware |
Date: |
Thu, 29 Jul 2010 18:15:38 +0900 |
On Thu, Jul 29, 2010 at 6:01 PM, Peter Bex <address@hidden> wrote:
> On Thu, Jul 29, 2010 at 05:34:27PM +0900, Nicolas Pelletier wrote:
>> >> Warning (#<thread: my-thread>): : (inexact->exact) inexact number
>> >> cannot be represented as an exact\
>> >> number: 1189553855.
>> >>
>> >
>> > I can not reproduce this. On what platform are you running this
>> > code?
>>
>> It is a 32-bit Linux on a Pentium R.
>
> That's why Felix couldn't reproduce it; I'm willing to bet he tried it
> on 64 bits only.
> This number cannot be represented as a fixnum on a 32 bit platform,
> because it requires 31 bits of storage. There are only 30 bits available,
> because one bit is used as fixnum tag and one bit is taken as the sign bit.
Yes. I know this from exchanging data between C and Scheme processes.
Values like 0x8000A010 were not going smoothly through at first.
> I'd suggest you use numbers but I don't think thread-sleep! accepts
> bignums.
For my current needs, I only need small fixnums, so using numbers is
enough, and seems like the way to go for an immediate solution.
>> As a workaround, I can use immediate integers instead of timeout
>> objects in the calls to thread-sleep! and mutex-lock!, at the expense
>> of a few milliseconds time slip.
>
> huh? I don't understand that bit.
I wanted to say the difference in behaviour between the two clocks
below, for example, is not an issue for my current program.
; a clock with a gradual drift:
(let loop ((x 1))
(thread-sleep! 1)
(write x)
(loop (+ x 1)))
; a clock with no drift:
(let ((start (time->seconds (current-time)))
(let loop ((x 1))
(thread-sleep! (seconds->time (+ x start)))
(write x)
(loop (+ x 1))))
Regards,
--
Nicolas