GNU bug report logs -
#47302
27.1; calc math-format-number formatting for floats without decimals is unusual
Previous Next
Reported by: Jelle Licht <jlicht <at> fsfe.org>
Date: Sun, 21 Mar 2021 21:55:02 UTC
Severity: normal
Tags: wontfix
Found in version 27.1
Done: Mattias Engdegård <mattiase <at> acm.org>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
Yes, that patch makes sense. Thanks, and thanks for helping with this old beast!
-- Dave
-----Original Message-----
From: Mattias Engdegård <mattiase <at> acm.org>
Sent: Sunday, April 25, 2021 8:54 AM
To: Dave Gillespie <Daveg <at> synaptics.com>
Cc: Jelle Licht <jlicht <at> fsfe.org>; Stefan Kangas <stefan <at> marxist.se>; 47302 <at> 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 <at> 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?
This bug report was last modified 4 years and 20 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.