From mboxrd@z Thu Jan 1 00:00:00 1970 From: Bastien Subject: Re: Incorrect sum of times in table Date: Mon, 01 Jul 2013 23:22:20 +0200 Message-ID: <87mwq6ugab.fsf@bzg.ath.cx> References: <87ppv2atvf.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:59783) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UtlYH-0000st-9r for emacs-orgmode@gnu.org; Mon, 01 Jul 2013 17:22:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UtlYG-0000Nn-9D for emacs-orgmode@gnu.org; Mon, 01 Jul 2013 17:22:25 -0400 Received: from mail-wg0-x231.google.com ([2a00:1450:400c:c00::231]:34321) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UtlYG-0000Nb-3O for emacs-orgmode@gnu.org; Mon, 01 Jul 2013 17:22:24 -0400 Received: by mail-wg0-f49.google.com with SMTP id a12so4255634wgh.16 for ; Mon, 01 Jul 2013 14:22:23 -0700 (PDT) In-Reply-To: <87ppv2atvf.fsf@gmail.com> (Nick Dokos's message of "Mon, 01 Jul 2013 16:49:08 -0400") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Nick Dokos Cc: emacs-orgmode@gnu.org Hi Nick, Nick Dokos writes: > I think you mean C-c +. > > The problem is that these things are calculated as decimal hours, using > floating point arithmetic and you get truncation towards 0 when the > value is printed out as an integer. The format in org-table-sum is > > (format "%d:%02d:%02d" h m s) > > but s is 0.9999... and it gets formatted as 0. > > It might be better to use > > (format "%.0f:%02.0f:%02.0f" h m s) > > i.e. as floating point with no places after the decimal point > (in which case the decimal point does not seem to be output). > But there may be other problems that I have not thought of. > It might be even better to round the floating point number to > the nearest integer and use %d formats instead: > > (format "%d:%02d:%02d" (round h) (round m) (round s)) Both solutions work -- we don't need to fear other problems here, `org-table-sum' is pretty isolated, so I'd say "please go ahead! and fix this in maint. Thanks, -- Bastien