[Cbor] Re: I-D Action: draft-mcnally-deterministic-cbor-10.html

Wolf McNally <wolf@wolfmcnally.com> Tue, 30 July 2024 23:38 UTC

Return-Path: <wolf@wolfmcnally.com>
X-Original-To: cbor@ietfa.amsl.com
Delivered-To: cbor@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id A6FADC14F615 for <cbor@ietfa.amsl.com>; Tue, 30 Jul 2024 16:38:39 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.907
X-Spam-Level:
X-Spam-Status: No, score=-1.907 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_ZEN_BLOCKED_OPENDNS=0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (2048-bit key) header.d=wolfmcnally-com.20230601.gappssmtp.com
Received: from mail.ietf.org ([50.223.129.194]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id b4V6gVJbhVYF for <cbor@ietfa.amsl.com>; Tue, 30 Jul 2024 16:38:39 -0700 (PDT)
Received: from mail-pl1-x630.google.com (mail-pl1-x630.google.com [IPv6:2607:f8b0:4864:20::630]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (P-256) server-digest SHA256) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 36B54C14F5EB for <cbor@ietf.org>; Tue, 30 Jul 2024 16:38:39 -0700 (PDT)
Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-1fd78c165eeso43705205ad.2 for <cbor@ietf.org>; Tue, 30 Jul 2024 16:38:39 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wolfmcnally-com.20230601.gappssmtp.com; s=20230601; t=1722382718; x=1722987518; darn=ietf.org; h=to:in-reply-to:cc:references:message-id:date:subject:mime-version :from:content-transfer-encoding:from:to:cc:subject:date:message-id :reply-to; bh=dqXuClSotUInBlqEJpMafkS/XECa+qMCaaKPJHpWJi0=; b=peQoqfM3Ytda4IisKEAlgNA37ccgTNsMMgOD17qXoxhXbMuQXVTGVJ5q5yl08O2/uj DbtM2guvwZ3HjGXUul2A+FTtlN4AfTwnERqd2ZBB47puSZxtgPNW4cqDv3ig1axYzlmf lk0b0cvB4zK5BFDPmkdy9YiOIxv3puSbvjZ8bxliuf6POo8TJ+mGqvwLFlwjjh5MrnE5 imqoH4RTZzUElCSQMJ+Jwo2bSFSyqFD4b6hERs9G4dj4JROH0jqKdXpDCO1Xz0dKuC+U tpK7ihMDkEJnfWs5xnq9KZFTh5THPf8wzuTtLVnimMDFWHVSrToDWaXZ6+/zlIBNw+BP Z+Hw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722382718; x=1722987518; h=to:in-reply-to:cc:references:message-id:date:subject:mime-version :from:content-transfer-encoding:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=dqXuClSotUInBlqEJpMafkS/XECa+qMCaaKPJHpWJi0=; b=K43cvAJaNic5J0TPUUJ6t1pN8k2g17j+o7jEJ60cqQp4wqNKKQvcVTbp/2JOwlLw10 qQ7dgA8eY9mTioFqeaERrvjb4eT8659Lk46S3epnTsinwu0OJRyad/dhhvYfykmceumL 0R2+MZmgM6xIZNo+i9zOJE43ZmH6/84FREE3+S/ZrDyKqkno+GNPivWVAox8YfLBR8SN q91jgzOfosEpYR+EJgPw4d/YKpbcBEYkk7dS/Cqjik7E3p0wJWRMPU1N417ZR+yc+xud 2yC6ch4IaR7usdKRwadmp7unU9cDEfECPiGKsaEuZcrHreWuZZ3ZICOGwl9XOTi5daMn uZWg==
X-Forwarded-Encrypted: i=1; AJvYcCUe6e+GHcApsLYQ9OzI/c1jVQaPcwXRJ2TG7jVMfYS5g2UHptNnq9OQ8ekmKWOkQec+jHX9L1swBkFCYoco
X-Gm-Message-State: AOJu0YwlNHA/ZM6SJOC7ydebtWGWs2VK1bB3xM3V9O59bOMjzQXgoI3n YZOZCGWsKTKbjNFh1vWp/9zMhgg/ffVlHfGdJURFUl4+CRuccR4Fcm4mCbHoSSw=
X-Google-Smtp-Source: AGHT+IG6cwd47PK2Tss6CwFs6dOyTn/T+eICUNes5jjPc96biJbsecCay+n6mF/1rS9bjVUR+TLnuA==
X-Received: by 2002:a17:902:e5ca:b0:1fd:9e6e:7c1f with SMTP id d9443c01a7336-1ff048df06amr176692025ad.56.1722382718177; Tue, 30 Jul 2024 16:38:38 -0700 (PDT)
Received: from smtpclient.apple ([2600:381:4d13:5c80:90e:e1e2:ae9:f578]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1fed7c7f650sm108222085ad.59.2024.07.30.16.38.37 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 30 Jul 2024 16:38:37 -0700 (PDT)
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: quoted-printable
From: Wolf McNally <wolf@wolfmcnally.com>
Mime-Version: 1.0 (1.0)
Date: Tue, 30 Jul 2024 16:38:26 -0700
Message-Id: <8375B4F4-A7C0-4C1B-A3B5-6E216D68AC06@wolfmcnally.com>
References: <A69EAB24-D21D-4D67-BADE-976991506FFE@wolfmcnally.com>
In-Reply-To: <A69EAB24-D21D-4D67-BADE-976991506FFE@wolfmcnally.com>
To: Anders Rundgren <anders.rundgren.net@gmail.com>
X-Mailer: iPhone Mail (21F90)
Message-ID-Hash: IABUQKFLGLP6FMXJZF3SC6PXKWQALP6A
X-Message-ID-Hash: IABUQKFLGLP6FMXJZF3SC6PXKWQALP6A
X-MailFrom: wolf@wolfmcnally.com
X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-cbor.ietf.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header
CC: Christopher Allen <ChristopherA@lifewithalacrity.com>, Joe Hildebrand <hildjj@cursive.net>, CBOR <cbor@ietf.org>, Shannon Appelcline <shannon.appelcline@gmail.com>, Carsten Bormann <cabo@tzi.org>, Laurence Lundblade <lgl@island-resort.com>
X-Mailman-Version: 3.3.9rc4
Precedence: list
Subject: [Cbor] Re: I-D Action: draft-mcnally-deterministic-cbor-10.html
List-Id: "Concise Binary Object Representation (CBOR)" <cbor.ietf.org>
Archived-At: <https://mailarchive.ietf.org/arch/msg/cbor/RAFCiVUQlp5OSW5wJpYCsz6qU4k>
List-Archive: <https://mailarchive.ietf.org/arch/browse/cbor>
List-Help: <mailto:cbor-request@ietf.org?subject=help>
List-Owner: <mailto:cbor-owner@ietf.org>
List-Post: <mailto:cbor@ietf.org>
List-Subscribe: <mailto:cbor-join@ietf.org>
List-Unsubscribe: <mailto:cbor-leave@ietf.org>

Here’s an interesting observation.

Go to the CBOR playground and paste in the following text to the left side, then encode and decode it.

[
    1.0,
    2.0,
    3.0,
    4.0
]

Here’s what you get back:

[1.0, 2.0, 3.0, 4.0]

What? It’s not the same! The white space has not been preserved.

Well, that’s no big deal when you understand that with CBOR, white space in diagnostic notation is semantically null, so CBOR doesn’t encode it.

In fact, if you round-trip it again, you get back the same result. Over and over.

Everything is working completely as intended and expected.

Now turn on the dCBOR checkbox and round-trip it again. You get back:

[1, 2, 3, 4]

What? It’s not the same! The decimal points have not been preserved.

Well, that’s no big deal when you understand that with dCBOR, a zero fractional part of a floating point value in diagnostic notation is semantically null, so dCBOR doesn’t encode it.

In fact, if you round-trip it again, you get back the same result. Over and over.

Everything is working completely as intended and expected.

~ Wolf