[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: ‘truncate’ on (float-time) causes arith range error on 32bit emacs
From: |
Göktuğ Kayaalp |
Subject: |
Re: ‘truncate’ on (float-time) causes arith range error on 32bit emacs |
Date: |
Wed, 03 Feb 2016 20:09:51 +0200 |
On Fri, 29 Jan 2016 10:49:27 +0200, Eli Zaretskii <eliz@gnu.org> writes:
> No. The usual ways of handling this are either (a) leave the numbers
> as floats, and just be more careful about comparisons; and (b)
> represent large numbers as cons cells.
>
> Since these are time values, I'd suggest (a) in your case. What math
> requires integers, exactly, and why?
Hi, I guess (a) will work, I just sent a patch to the user to test (I do
not have a 32bit machine, though the math worked). This is what the
function does:
(defun forecast--sun-position-graphic ()
"Visualise the time since the rise of the sun and the time to the set
thereof.
E.g.:
Quasi-midday:
>————————☉———————————<
Sunrise:
☉————————————————————<
Sunset:
>————————————————————☉"
(let* ((today (aref (forecast--assoca '(daily data) forecast--data) 0))
(sunrise (forecast--assoca '(sunriseTime) today))
(sunset (forecast--assoca '(sunsetTime) today))
(now (truncate (float-time)))
(daylen (- sunset sunrise))
(sunsec (- now sunrise))
(wwidth (window-body-width))
(graph (concat ">" (make-string (- wwidth 5) ?—) "<"))
(sun ?☉)
(pos (cond
((< sunrise sunset now) (- wwidth 4))
((> sunrise now) 0)
(t (1- (/ sunsec (/ daylen wwidth)))))))
(aset graph pos sun)
graph))
The values ‘sunrise’ and ‘sunset’ come from an API and they are integer
timestamps.
Sorry for the late reply, I somehow did not receive the replies to my
message, I've some problems with e-mail. Please CC me directly if you
reply, I'm not subscribed to the list.
Thanks a lot,
-gk.
--
İ. Göktuğ Kayaalp.
http://gkayaalp.com/
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: ‘truncate’ on (float-time) causes arith range error on 32bit emacs,
Göktuğ Kayaalp <=