From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: Improving JSON pretty printing, how to represent floats? Date: Fri, 05 Apr 2024 15:35:22 +0300 Message-ID: <86bk6o56np.fsf@gnu.org> References: <87msq8w2zm.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="38508"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: =?utf-8?Q?G=C3=A9za_Herman?= Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Apr 05 14:36:25 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 1rsinx-0009pG-El for ged-emacs-devel@m.gmane-mx.org; Fri, 05 Apr 2024 14:36:25 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rsin5-00030t-Hb; Fri, 05 Apr 2024 08:35:31 -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 1rsin3-0002uz-9f for emacs-devel@gnu.org; Fri, 05 Apr 2024 08:35:29 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rsin2-0001Dm-Uu; Fri, 05 Apr 2024 08:35:28 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=R0+0bzKOPGyeZkBJwYwEwakm90EBdYil+GWVbFE+U6c=; b=LjhK4aUTcoBemI/f4ynN 7HoAw3drIoX06gxC7l7pNL22eU/MLxGJ5x9o1IsT+xnHraqxeKdKy/4Bv0qsYyX6Y9Vvo3zgE9Z39 G1Q+cdeRUhiemTPOU1oLD34v+PjjNhRu3JvTrR/FHln4nWv1kMvsIlhB930/Q1O756Jm34YPhErh/ JPPovcwmdxT9ilunLrsauseJ+Ad2FOfOEGEuqVbpxloCHdWwBHf/dATkK2PgP0P+ynne20yrOtDfL tvCuGLy8IXjTPPipSP/CFavmyNol7DuSmfpTFwak3vyVNPCpIiYQjnvymwpudHsSixDTyKzQWgLLE AzgpjXJEG6wNXg==; In-Reply-To: <87msq8w2zm.fsf@gmail.com> (message from Herman, =?utf-8?Q?G?= =?utf-8?Q?=C3=A9za?= on Fri, 05 Apr 2024 11:39:10 +0200) 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:317541 Archived-At: > From: Herman, Géza > Date: Fri, 05 Apr 2024 11:39:10 +0200 > > There is a thing that I don't like about the current > json-pretty-print: as it parses floats, pretty printing can be > lossy. If one pretty prints this > > --8<---------------cut here---------------start------------->8--- > { > "a": 3.333333333333000000000000000001 > } > --8<---------------cut here---------------end--------------->8--- > > then the float gets rounded. I think pretty printing should be > lossless (keeping the exact format, exp notation, etc.). The digits in 3.333333333333000000000000000001 after 16th digit are meaningless: they aren't supported by IEEE floating-point standard, so they are just numerical noise. Thus, talking about "lossless" wrt them makes little sense to me.