|
From: | felix |
Subject: | Re: [Chicken-users] Re: time/date |
Date: | Thu, 27 Mar 2003 22:14:00 +0100 |
User-agent: | Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0.0) Gecko/20020529 |
Anthony Carrico wrote:
On Thu, Mar 27, 2003 at 03:26:46PM +0100, Felix Winkelmann wrote:Hi! Just change the "int" argument type-specifier in posix.scm (line 1137) to "integer". Sorry.I think I'm still missing something. When working with time values, how do I specify 32bit integer literals, do 32bit arithmetic, etc.? (define seconds->string2 (let ([ctime (foreign-lambda c-string "C_ctime" integer)]) (lambda (secs) (let ([str (ctime secs)]) (unless str (##sys#error 'seconds->string2 "can not convert seconds to string" secs)) str)))) (display (seconds->string2 1073741823)) (newline) (display (seconds->string2 1073741824)) (newline) bash-2.05b$ chicken test.scm compiling `test.scm' ... Warning: exact literal exceeds range in line 9 "1073741824"
Never mind that warning. It is just there to remind you that the integer constant will be compiled as a flonum literal. (Should I remove that warning). Everything that doesn't fit into a fixnum (31-bit signed), will be coerced to a flonum (64-bit double). Everything beyond what fits into that will have to wait for bignum support. Passing flonums to C code that wants 32-bit ints is safe, as long as the value fits into that range (and as long as you use the "integer" type-specifier. "int" is only for fixnum-range. That is not very intuitive, I admit). cheers, felix
[Prev in Thread] | Current Thread | [Next in Thread] |