unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Re: ‘truncate’ on (float-time) causes arith range error on 32bit emacs
@ 2016-02-03 18:09 Göktuğ Kayaalp
  0 siblings, 0 replies; 4+ messages in thread
From: Göktuğ Kayaalp @ 2016-02-03 18:09 UTC (permalink / raw)
  To: eliz; +Cc: help-gnu-emacs

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/



^ permalink raw reply	[flat|nested] 4+ messages in thread
* ‘truncate’ on (float-time) causes arith range error on 32bit emacs
@ 2016-01-29  3:02 Göktuğ Kayaalp
  2016-01-29  8:49 ` Eli Zaretskii
  2016-01-29  9:55 ` Andy Moreton
  0 siblings, 2 replies; 4+ messages in thread
From: Göktuğ Kayaalp @ 2016-01-29  3:02 UTC (permalink / raw)
  To: help-gnu-emacs

Hi all,

I've a little package [1].  A user reported to me this error:

  Contacting host: api.forecast.io:443
  Opening TLS connection to `api.forecast.io'...
  Opening TLS connection with `gnutls-cli --insecure -p 443 api.forecast.io'...done
  Opening TLS connection to `api.forecast.io'...done
  error in process sentinel: let*: Arithmetic range error: "truncate", 1454005216.6590292
  error in process sentinel: Arithmetic range error: "truncate", 1454005216.6590292
  error in process filter: let*: Arithmetic range error: "truncate", 1454005218.8166773
  error in process filter: Arithmetic range error: "truncate", 1454005218.8166773
  error in process sentinel: let*: Arithmetic range error: "truncate", 1454005220.8661127
  error in process sentinel: Arithmetic range error: "truncate", 1454005220.8661127

He is  on a  32bit pc.   These errors come  from a  function in  which I
truncate some timestamps for some math that requires integers.  Is there
a way to convert it to integer w/o error on a 32 bit machine?

Interestingly, these values  don't seem to exceed the limits  for 32 bit
integers, am I wrong?   Is there sth. different going on  that I did not
catch?   I'm  rather  novice  with   elisp,  so  sorry  if  I'm  missing
sth. obvious and blundering the list.

[1] http://gkayaalp.com/emacs.html#forecast.el

Cheers,
 -gk

-- 
İ. Göktuğ Kayaalp.
http://gkayaalp.com/



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-02-03 18:09 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-03 18:09 ‘truncate’ on (float-time) causes arith range error on 32bit emacs Göktuğ Kayaalp
  -- strict thread matches above, loose matches on Subject: below --
2016-01-29  3:02 Göktuğ Kayaalp
2016-01-29  8:49 ` Eli Zaretskii
2016-01-29  9:55 ` Andy Moreton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).