bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#47302: 27.1; calc math-format-number formatting for floats without d


From: Dave Gillespie
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

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?






reply via email to

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