From: "Göktuğ Kayaalp" <self@gkayaalp.com>
To: eliz@gnu.org
Cc: help-gnu-emacs@gnu.org
Subject: Re: ‘truncate’ on (float-time) causes arith range error on 32bit emacs
Date: Wed, 03 Feb 2016 20:09:51 +0200 [thread overview]
Message-ID: <877filoec0.fsf@xi.bootis> (raw)
In-Reply-To: 83wpqsydm0.fsf@gnu.org
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/
next reply other threads:[~2016-02-03 18:09 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-03 18:09 Göktuğ Kayaalp [this message]
-- strict thread matches above, loose matches on Subject: below --
2016-01-29 3:02 ‘truncate’ on (float-time) causes arith range error on 32bit emacs Göktuğ Kayaalp
2016-01-29 8:49 ` Eli Zaretskii
2016-01-29 9:55 ` Andy Moreton
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=877filoec0.fsf@xi.bootis \
--to=self@gkayaalp.com \
--cc=eliz@gnu.org \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.