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
[Message part 1 (text/plain, inline)]
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?
[calc-digit-after-point.diff (application/octet-stream, attachment)]
This bug report was last modified 4 years and 19 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.