From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Newsgroups: gmane.emacs.devel Subject: Re: Improving JSON pretty printing, how to represent floats? Date: Fri, 5 Apr 2024 16:01:01 +0200 Message-ID: References: <87msq8w2zm.fsf@gmail.com> <86bk6o56np.fsf@gnu.org> <87bk6o55ci.fsf@gmail.com> <867chc5526.fsf@gnu.org> <877chc5417.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="helqvnkh+OIJpCiz" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="5975"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Eli Zaretskii , emacs-devel@gnu.org To: =?utf-8?Q?Herman=2C_G=C3=A9za?= Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Apr 05 16:02:06 2024 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rsk8s-0001KG-Mz for ged-emacs-devel@m.gmane-mx.org; Fri, 05 Apr 2024 16:02:06 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rsk80-0005Jb-5J; Fri, 05 Apr 2024 10:01:12 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rsk7w-0005JR-OF for emacs-devel@gnu.org; Fri, 05 Apr 2024 10:01:09 -0400 Original-Received: from mail.tuxteam.de ([5.199.139.25]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rsk7s-0006FJ-LR; Fri, 05 Apr 2024 10:01:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tuxteam.de; s=mail; h=From:In-Reply-To:Content-Type:MIME-Version:References:Message-ID: Subject:Cc:To:Date:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=Q07KUt5nmHIWe/bYIqsYYJbNpJDXyfFjYU0PULFfKaw=; b=O45lFrWWBfFpiAl09YZLtU6gLs 9sGCZeD22I6tuwQlEiWd4LZ2vBPRcz5vFYYgdZox1s5y4dWZPDQcV23g5Ljmx/BgiIwfLkP1xl+va RvIwQFEk08zD11XwtQ8a6PnAuziSYRHae2Oe5vKcvyzZzKDJBHUl6WgFmKe/3Nfr3TuSYzSD2Y1hH H1J0LgT2q74pU2O6duB0ovdT0spFh0H47PZgeGi23bPz63zW4AkOlksa181m/sST1lLBS+sP0Kh0L w3Vi7bOAPmrDHA06LIjaGUul9T1c9uTQBcL6JPbGUfNuJGgGMHQWuh/90eq1ZSzSXhEsiPCJSiQMu aLZbGXqw==; Original-Received: from tomas by mail.tuxteam.de with local (Exim 4.94.2) (envelope-from ) id 1rsk7p-0006mc-1D; Fri, 05 Apr 2024 16:01:01 +0200 Content-Disposition: inline In-Reply-To: <877chc5417.fsf@gmail.com> Received-SPF: pass client-ip=5.199.139.25; envelope-from=tomas@tuxteam.de; helo=mail.tuxteam.de X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:317548 Archived-At: --helqvnkh+OIJpCiz Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Apr 05, 2024 at 03:16:44PM +0200, Herman, G=C3=A9za 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 --=20 t --helqvnkh+OIJpCiz Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EABECAB0WIQRp53liolZD6iXhAoIFyCz1etHaRgUCZhAEFgAKCRAFyCz1etHa Rj0rAJ0WEfRY+GHFiHKJyYomg4tVk+HHlQCfd1LCguZJ9j9hND12nLEHzLls5Hw= =EzAI -----END PGP SIGNATURE----- --helqvnkh+OIJpCiz--