From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?utf-8?Q?Herman=2C_G=C3=A9za?= Newsgroups: gmane.emacs.devel Subject: Re: Improving JSON pretty printing, how to represent floats? Date: Fri, 05 Apr 2024 14:55:26 +0200 Message-ID: <87bk6o55ci.fsf@gmail.com> References: <87msq8w2zm.fsf@gmail.com> <86bk6o56np.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="37961"; mail-complaints-to="usenet@ciao.gmane.io" Cc: =?utf-8?Q?G=C3=A9za?= Herman , emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Apr 05 15:04:32 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 1rsjF8-0009eM-Vh for ged-emacs-devel@m.gmane-mx.org; Fri, 05 Apr 2024 15:04:30 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rsjET-00056g-Ql; Fri, 05 Apr 2024 09:03:49 -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 1rsjER-00056L-D9 for emacs-devel@gnu.org; Fri, 05 Apr 2024 09:03:47 -0400 Original-Received: from mail-ej1-x630.google.com ([2a00:1450:4864:20::630]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rsjEP-0005si-Pi; Fri, 05 Apr 2024 09:03:47 -0400 Original-Received: by mail-ej1-x630.google.com with SMTP id a640c23a62f3a-a44ad785a44so266065966b.3; Fri, 05 Apr 2024 06:03:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712322223; x=1712927023; darn=gnu.org; h=content-transfer-encoding:mime-version:message-id:in-reply-to:date :subject:cc:to:from:references:from:to:cc:subject:date:message-id :reply-to; bh=bgIMtE3QaK48QX3D2Vq4RuBrWbuSrPIr9OWypg/aHSE=; b=cFK7pzOFYDAzVgMk0XT9RrRJ7x4xrpfgkYCwOwBMg3kwJb87HFToh8KSftJ6ICFQ7s S5SI1TjYLYNWvXWL7Gal8MgrS+Cr6wlnYPncaohyiR9lJIQ23VeYMV+JW9FeaBI5Uhv9 hwC0zqed7p5q2hyVr8nq2VuavmGcXxhYePgIUwlRJioArlbhTZEkSZwZtJ+nocLWpNy5 1qDV6HE/fClwbaP8xFGoQOnfNx2FHG7oUurvQ37LJweAakKrC2/MyUEU+1lAKwa+qfUg tSAHlbqGdRwlOYLkTQLLUCbdTWK7KhrUm+DJOJPZvkATbHnZA8PuZ5egT+Y7Z0+VjzO0 i3Vw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712322223; x=1712927023; h=content-transfer-encoding:mime-version:message-id:in-reply-to:date :subject:cc:to:from:references:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=bgIMtE3QaK48QX3D2Vq4RuBrWbuSrPIr9OWypg/aHSE=; b=g5gbCXJaanyNkMYYBdmtwkmwOAri3UbPONALTlTxqxYox3GPSen7Bdy+5aX07Ny4nL xQEQsot09WsMLbY+//qblIeQ60FHFiEZVbpOBMUS4cy25R/Kdu7GJTe01AYNrwiwV2uG PqHWutcYUAflSHhk3ORRvJB/aV5gauHf2WY90UEWNERk9abU0JlCKcx+NHLoLGI32ZYF RRlTnmtvGLwcTtCpgV/MyTMh+X/yDNSCLVSollol1McqqpYAyT7ej46q4RFQmkINgR7t LFiFwsHjk0cVoTBHXoL26H4JDisiiaASxC9i3Ogs5PnEVPlDGOfBAExY184CWkOSqpMG sb4w== X-Forwarded-Encrypted: i=1; AJvYcCUS+2Wf5Au+nGkJjgXPl5/nhH21UGCBPSSdseZTTN4bkHUxjfpiaxZpf8z6hA5ZzS2xpGQ4HRKLCGfVzp87474She6A X-Gm-Message-State: AOJu0YzgUGndMblVbvCfe/rO/QRXsFu4Lz9/UEjoLha+csyceku1Eciy ZsGJDxfup2P0UgyyImzXC2Ls1qzF3rbm9akKJNYn1krkMh9gyfwOGADs6tCc X-Google-Smtp-Source: AGHT+IHdBLH+iMorMNToZDIllk3u1aakdsIciNTrW1cwZD7ZsexddwOHrV7LaGWyaC3AeEtNaCR4XA== X-Received: by 2002:a17:906:fb19:b0:a4f:7e40:5121 with SMTP id lz25-20020a170906fb1900b00a4f7e405121mr1032357ejb.30.1712322223063; Fri, 05 Apr 2024 06:03:43 -0700 (PDT) Original-Received: from localhost (62-77-231-86.static.invitel.hu. [62.77.231.86]) by smtp.gmail.com with ESMTPSA id qc13-20020a170906d8ad00b00a5194b5b932sm823999ejb.16.2024.04.05.06.03.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Apr 2024 06:03:42 -0700 (PDT) In-reply-to: <86bk6o56np.fsf@gnu.org> Received-SPF: pass client-ip=2a00:1450:4864:20::630; envelope-from=geza.herman@gmail.com; helo=mail-ej1-x630.google.com 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, 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:317544 Archived-At: Eli Zaretskii writes: >> From: Herman, G=C3=A9za >> 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=20 >> here---------------start------------->8--- >> { >> "a": 3.333333333333000000000000000001 >> } >> --8<---------------cut=20 >> 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=20 > are > meaningless: they aren't supported by IEEE floating-point=20 > standard, so > they are just numerical noise. Thus, talking about "lossless"=20 > wrt > them makes little sense to me. You mean the 64-bit binary format. IEEE-754 describes more formats=20 which have more precision, and also there are more formats used in=20 practice than what IEEE-754 describes. Plus, I don't think that the JSON standard mandates IEEE-754=20 numbers. It just describes numbers, so I think it's good behavior=20 to not change numbers during formatting.