all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Charles Millar <millarc@verizon.net>
To: "emacs-orgmode@gnu.org" <emacs-orgmode@gnu.org>
Subject: Fwd: Bug: Final zero after decimal point is stripped when inline code evaluated
Date: Tue, 7 May 2024 10:31:28 -0400	[thread overview]
Message-ID: <419e419c-9df7-4bb1-97b7-aa19fc48bcc8@verizon.net> (raw)
In-Reply-To: <aad9bb0b-4b64-4934-952d-a6cdc9f3b32f@verizon.net>




-------- Forwarded Message --------
Subject: Re: Bug: Final zero after decimal point is stripped when inline 
code evaluated
Date: Tue, 7 May 2024 10:25:05 -0400
From: Charles Millar <millarc@verizon.net>
To: Max Nikulin <manikulin@gmail.com>

On 5/7/24 7:49 AM, Max Nikulin wrote:
> On 07/05/2024 03:05, Charles Millar wrote:
>> I appreciate that mathematically a trailing zero or zeros may be 
>> non-significant; however, in my use case, i.e. correct format in a 
>> text, they are necessary. Another example, in addition to my Dollars 
>> and cents scenario, may be a table that that has been created by using 
>> append, and the table appears as follows because trailing zeros were 
>> disregarded.
>>
>> This 1.222
>> that 3.444
>> it   5.6
>> last 7.691
>>
>> Question arises - is the correct number reported on line "it" 5.600 or 
>> has some editing omitted the last two decimal places?
> 
> I am unsure what do you mean by "using append".

Nor sure myself! What I meant was each number in the second column was a 
result of a :var evaluation that called a table and that there was a 
different table for each number.

>  From my point of view there are 2 cases:
> - When output format is fixed
>    | 2 | 1.41 |
>    | 3 | 1.73 |
>    #+TBLFM: $2=(sqrt $1);%.2f
> - When calculations should be performed with fixed point,
>    usual floating point representation gives unexpected results
>    src_elisp{(- 0.3 (+ 0.1 0.1 0.1))}
>    {{{results(=-5.551115123125783e-17=)}}}
> 
> Some programming languages have decimal type for numbers:
> https://docs.python.org/3/library/decimal.html
> 
> As to finances, I was surprised that ledger, hledger, and beancount have 
> different internal representations for amounts and there are various 
> issues with rounding.
> 
> Org just should avoid unnecessary conversions between strings an 
> numbers, but Ihor is right and implementation would require enough efforts.
> 
>> (setq toconvert 5.000)
>> (number-to-string toconvert)
>>
>> evaluates to "5".
> 
> I get "5.0" (Linux), so I suspect some mistake.
> 
> 
> 
I am using Debian Testing, full upgrade as of last Saturday.


  parent reply	other threads:[~2024-05-07 14:32 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <144951b9-d715-4fd6-a3f5-2462ff98acb0.ref@verizon.net>
2024-05-05 18:30 ` Bug: Final zero after decimal point is stripped when inline code evaluated Charles Millar
2024-05-05 18:41   ` Charles Millar
2024-05-06 12:44   ` Ihor Radchenko
2024-05-06 16:36     ` Max Nikulin
2024-05-06 16:42       ` Ihor Radchenko
2024-05-06 20:05         ` Charles Millar
2024-05-07 11:49           ` Max Nikulin
     [not found]             ` <aad9bb0b-4b64-4934-952d-a6cdc9f3b32f@verizon.net>
2024-05-07 14:31               ` Charles Millar [this message]
2024-05-07 16:40               ` Max Nikulin

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=419e419c-9df7-4bb1-97b7-aa19fc48bcc8@verizon.net \
    --to=millarc@verizon.net \
    --cc=emacs-orgmode@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.