* how to avoid floating number problems with org-table for finances?
@ 2012-10-12 17:06 Thomas Koch
2012-10-12 18:00 ` Johan Sandblom
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Thomas Koch @ 2012-10-12 17:06 UTC (permalink / raw)
To: emacs-orgmode
Hi,
I use a simple org-mode table to sum up the expenses and incomes of a small
private project. Now I remembered that I should know as a programmer to NEVER
EVER USE FLOATS FOR FINANCES!!!
But I did...
| 0.3 |
| 0.3 |
| 0.3 |
| 0.9000000000000000222044604925031308084726 |
#+TBLFM: @4$1=vsum(@1..@3);%.40f
Do you know any quirck how I can continue using point notation but be sure
that the numbers are added correctly? I think I'd need another vsum method
that would
- find the number of decimal points of the most precise field
- parse all numbers to integers by filling up zeros at the end and ignoring
the decimal point
- sum up
- write the result with a decimal point at the right position
Best regards,
Thomas Koch, http://www.koch.ro
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: how to avoid floating number problems with org-table for finances?
2012-10-12 17:06 how to avoid floating number problems with org-table for finances? Thomas Koch
@ 2012-10-12 18:00 ` Johan Sandblom
2012-10-12 18:04 ` Johan Sandblom
2012-11-01 18:04 ` Michael Brand
2 siblings, 0 replies; 4+ messages in thread
From: Johan Sandblom @ 2012-10-12 18:00 UTC (permalink / raw)
To: thomas; +Cc: emacs-orgmode
Not what you asked for, but how about simply rounding it?
2012-10-12 19:06 skrev Thomas Koch:
> | 0.9000000000000000222044604925031308084726 |
> #+TBLFM: @4$1=vsum(@1..@3);%.40f
#+TBLFM: @4$1=round(vsum(@1..@3);%.40f
--
Johan Sandblom, MD PhD
m +46735521477
What is wanted is not the will to believe, but the
will to find out, which is the exact opposite
--Bertrand Russell
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: how to avoid floating number problems with org-table for finances?
2012-10-12 17:06 how to avoid floating number problems with org-table for finances? Thomas Koch
2012-10-12 18:00 ` Johan Sandblom
@ 2012-10-12 18:04 ` Johan Sandblom
2012-11-01 18:04 ` Michael Brand
2 siblings, 0 replies; 4+ messages in thread
From: Johan Sandblom @ 2012-10-12 18:04 UTC (permalink / raw)
To: thomas; +Cc: emacs-orgmode
Sorry, I meant
#+TBLFM: @4$1=round(vsum(@1..@3),2);%.40f
Johan
--
Johan Sandblom, MD PhD
m +46735521477
What is wanted is not the will to believe, but the
will to find out, which is the exact opposite
--Bertrand Russell
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: how to avoid floating number problems with org-table for finances?
2012-10-12 17:06 how to avoid floating number problems with org-table for finances? Thomas Koch
2012-10-12 18:00 ` Johan Sandblom
2012-10-12 18:04 ` Johan Sandblom
@ 2012-11-01 18:04 ` Michael Brand
2 siblings, 0 replies; 4+ messages in thread
From: Michael Brand @ 2012-11-01 18:04 UTC (permalink / raw)
To: thomas; +Cc: emacs-orgmode
Hi Thomas
I hope it’s not too late but I got into some backlog with reading the list.
On Fri, Oct 12, 2012 at 7:06 PM, Thomas Koch <thomas@koch.ro> wrote:
> #+TBLFM: @4$1=vsum(@1..@3);%.40f
For your example I would recommend:
#+TBLFM: @4$1=vsum(@1..@3); f-2
or if you really want 40 digits precision for the calculations behind:
#+TBLFM: @4$1=vsum(@1..@3); p40 f-2
Please read my explanations here:
http://orgmode.org/worg/org-faq.html#table-high-precision
The integer calculation you suggested with decimal point notation is
not possible out of the box and if at all I would rather go the way of
Calc Fractions to get infinite precision:
| 3:10 |
| 3:10 |
| 3:10 |
| 9:10 |
#+TBLFM: @4$1=vsum(@1..@3); F
Michael
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-11-01 18:04 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-12 17:06 how to avoid floating number problems with org-table for finances? Thomas Koch
2012-10-12 18:00 ` Johan Sandblom
2012-10-12 18:04 ` Johan Sandblom
2012-11-01 18:04 ` Michael Brand
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.