From: Dave Gillespie <Daveg@synaptics.com>
To: "Mattias Engdegård" <mattiase@acm.org>
Cc: Jelle Licht <jlicht@fsfe.org>, Stefan Kangas <stefan@marxist.se>,
"47302@debbugs.gnu.org" <47302@debbugs.gnu.org>
Subject: bug#47302: 27.1; calc math-format-number formatting for floats without decimals is unusual
Date: Mon, 26 Apr 2021 14:58:12 +0000 [thread overview]
Message-ID: <BYAPR03MB35924FCDDEC6B174F03E28F4BC429@BYAPR03MB3592.namprd03.prod.outlook.com> (raw)
In-Reply-To: <0E7C5A4F-105A-4E1E-A103-BFB9C263F2BA@acm.org>
Yes, that patch makes sense. Thanks, and thanks for helping with this old beast!
-- Dave
-----Original Message-----
From: Mattias Engdegård <mattiase@acm.org>
Sent: Sunday, April 25, 2021 8:54 AM
To: Dave Gillespie <Daveg@synaptics.com>
Cc: Jelle Licht <jlicht@fsfe.org>; Stefan Kangas <stefan@marxist.se>; 47302@debbugs.gnu.org
Subject: Re: bug#47302: 27.1; calc math-format-number formatting for floats without decimals is unusual
CAUTION: Email originated externally, do not click links or open attachments unless you recognize the sender and know the content is safe.
22 apr. 2021 kl. 18.35 skrev Dave Gillespie <Daveg@synaptics.com>:
> Wow, it has been a long time since I got any correspondence on Calc!
Good to hear from you, Dave! I just fix the occasional Calc bug now and then.
> Calc has a C language mode ('d C' keystroke, controlled by calc-language). It is a good point that C mode (and probably others like it) should format integer-valued floats as "123.0" even if the default mode does not. If we apply Jelle's patch, I suggest making it conditional on calc-language so that it applies only in modes such as C mode. Or perhaps rework it as a text transformation using calc-language-filter.
>
> You could even create a JSON language mode, but most likely the basic C mode is close enough to serve that purpose.
These are all good suggestions. Most languages permit trailing decimal points; the only common exceptions that I can think of are Haskell, Ada and Swift. Apparently JSON is also one. Tying the float-format display to the C, Pascal (etc) modes seems a bit incongruous as it has nothing to do with the syntax of those languages.
How to display a floating-point number with zero fraction also depends on what the user wants to do with the result, so there is a good argument for letting him or her do the required post-processing. Sometimes '1.' should become '1.0', sometimes '1'. For instance, in a LaTeX document it would depend on how the author wants to represent significant digits. A JSON parser (such as the one in Emacs) will parse '1.0' and '1' differently, as a float or integer respectively.
I wrote the patch below as a possible solution but in the light of the above, perhaps it's not ideal?
next prev parent reply other threads:[~2021-04-26 14:58 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-21 21:54 bug#47302: 27.1; calc math-format-number formatting for floats without decimals is unusual Jelle Licht
2021-04-21 15:16 ` Stefan Kangas
2021-04-22 13:44 ` Mattias Engdegård
2021-04-22 15:03 ` Jelle Licht
2021-04-22 16:35 ` Dave Gillespie
2021-04-25 15:53 ` Mattias Engdegård
2021-04-26 14:58 ` Dave Gillespie [this message]
2021-04-27 16:15 ` Mattias Engdegård
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=BYAPR03MB35924FCDDEC6B174F03E28F4BC429@BYAPR03MB3592.namprd03.prod.outlook.com \
--to=daveg@synaptics.com \
--cc=47302@debbugs.gnu.org \
--cc=jlicht@fsfe.org \
--cc=mattiase@acm.org \
--cc=stefan@marxist.se \
/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 public inbox
https://git.savannah.gnu.org/cgit/emacs.git
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).