emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] Incorrect sum of times in table


From: Bastien
Subject: Re: [O] Incorrect sum of times in table
Date: Mon, 01 Jul 2013 23:22:20 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)

Hi Nick,

Nick Dokos <address@hidden> 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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]