unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: <tomas@tuxteam.de>
To: "Herman, Géza" <geza.herman@gmail.com>
Cc: Eli Zaretskii <eliz@gnu.org>, emacs-devel@gnu.org
Subject: Re: Improving JSON pretty printing, how to represent floats?
Date: Fri, 5 Apr 2024 16:01:01 +0200	[thread overview]
Message-ID: <ZhAEHVLlmOeUANid@tuxteam.de> (raw)
In-Reply-To: <877chc5417.fsf@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 873 bytes --]

On Fri, Apr 05, 2024 at 03:16:44PM +0200, Herman, Géza wrote:

[...]

> I don't think it's relevant here.  If I reformat a JSON, it should really be
> a formatting operation, it shouldn't matter what kind of floating point
> numbers a platform supports.  We are not talking about reading a JSON, but
> formatting it [...]

It seems you have no choice but to keep the string representation around,
then. There are other possible anomalies with numbers, like "leading zeros",
where a conversion to number and back would transform 0042 -> 42. Likewise
with 1e2 -> 100 and so on. When transformed into numbers, you lose that
information.

Note that 0.2 is an infinite binary fraction, i.e. if you go binary and
back under most JSON implementations, you'd always get a result depending
on the underlying precision, rounding strategies, etc.

Cheers
-- 
t

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

  reply	other threads:[~2024-04-05 14:01 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-05  9:39 Improving JSON pretty printing, how to represent floats? Herman, Géza
2024-04-05 12:35 ` Eli Zaretskii
2024-04-05 12:53   ` Mattias Engdegård
2024-04-05 12:55   ` Herman, Géza
2024-04-05 13:09     ` Eli Zaretskii
2024-04-05 13:16       ` Herman, Géza
2024-04-05 14:01         ` tomas [this message]
2024-04-05 15:34         ` Eli Zaretskii
2024-04-05 16:46           ` Herman, Géza
2024-04-05 13:37 ` Dmitry Gutov
2024-04-05 14:20   ` Herman, Géza
2024-04-05 16:47     ` Dmitry Gutov
2024-04-05 14:18 ` Mattias Engdegård
2024-04-05 14:25   ` Herman, Géza

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=ZhAEHVLlmOeUANid@tuxteam.de \
    --to=tomas@tuxteam.de \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=geza.herman@gmail.com \
    /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).