GNU bug report logs - #47302
27.1; calc math-format-number formatting for floats without decimals is unusual

Previous Next

Package: emacs;

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

From: Dave Gillespie <Daveg <at> synaptics.com>
To: Jelle Licht <jlicht <at> fsfe.org>, Mattias Engdegård <mattiase <at> acm.org>, Stefan Kangas <stefan <at> marxist.se>
Cc: "47302 <at> debbugs.gnu.org" <47302 <at> debbugs.gnu.org>
Subject: bug#47302: 27.1; calc math-format-number formatting for floats without decimals is unusual
Date: Thu, 22 Apr 2021 16:35:25 +0000
Wow, it has been a long time since I got any correspondence on Calc!

Yes, I used the notation "123." versus "123.0" with the goal to keep the output concise for casual interactive users.  I agree with Mattias that it is best to leave the default as it is.

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.

Thanks!

                                                                -- Dave



-----Original Message-----
From: Jelle Licht <jlicht <at> fsfe.org> 
Sent: Thursday, April 22, 2021 8:04 AM
To: Mattias Engdegård <mattiase <at> acm.org>; Stefan Kangas <stefan <at> marxist.se>
Cc: 47302 <at> debbugs.gnu.org; Dave Gillespie <Daveg <at> synaptics.com>
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.


Mattias Engdegård <mattiase <at> acm.org> writes:

> 21 apr. 2021 kl. 17.16 skrev Stefan Kangas <stefan <at> marxist.se>:
>>
>> Jelle Licht <jlicht <at> fsfe.org> writes:
>
>>> (calc-eval "123.0") ; => "123."
>>> (calc-eval "0.0") ; => "0."
>>>
>>> I would expect this output to be either "123.0" or "123" and "0.0" or
>>> "0" respectively.
>
> Jelle, thanks for the report!
>
> Calc distinguishes integers from floating-point numbers by the presence of a decimal point, so removing it is probably not a good idea. The lack of a trailing 0 after the decimal point is clearly intended but mainly a cosmetic issue; it's uncommon in hand-writing but not in computerese.
>
> We could put a 0 after the decimal point but not doing so saves some space in the often narrow Calc windows. I'd suggest leaving it as it is. The notation is distinctive enough that there is no serious risk of misunderstanding.
>
> If you disagree, do say.
Hi Mattias,

It would be nice to have a (formatting) option to print 'full'
floating-point numbers. There are a lot of other knobs to tweak
w.r.t. printing numbers, so in that sense it does not seem totally
inconceivable for such a thing to exist.

The context in which I would use this is one where the output of calc is
being used by other programs and data formats (e.g. JSON). For now, I'll
just have to have emacs read and then subsequently print the result of
my calc-adventures, which works fine.

Thanks for the consideration,
 - Jelle

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.