[Cbor] Re: Dealing with -0.0, NaN, and Infinity
Anders Rundgren <anders.rundgren.net@gmail.com> Wed, 21 August 2024 10:44 UTC
Return-Path: <anders.rundgren.net@gmail.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 5FF44C1519BB for <cbor@ietfa.amsl.com>; Wed, 21 Aug 2024 03:44:23 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.105
X-Spam-Level:
X-Spam-Status: No, score=-2.105 tagged_above=-999 required=5 tests=[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_ZEN_BLOCKED_OPENDNS=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, URIBL_BLOCKED=0.001, URIBL_DBL_BLOCKED_OPENDNS=0.001, URIBL_ZEN_BLOCKED_OPENDNS=0.001] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.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 p9iQ2d2pRjCM for <cbor@ietfa.amsl.com>; Wed, 21 Aug 2024 03:44:19 -0700 (PDT)
Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) (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 47EB9C15109E for <cbor@ietf.org>; Wed, 21 Aug 2024 03:44:19 -0700 (PDT)
Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-428243f928fso71406515e9.0 for <cbor@ietf.org>; Wed, 21 Aug 2024 03:44:19 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724237057; x=1724841857; darn=ietf.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=zsXwwmVFE029w8OM4jI2xr8ALMyz0YfGcUY2KSYuOHI=; b=LvYglZOHZwYhgTSv3VrYse1ri06sKZz1IqlPcwmMDCWpNR9EijIVt+mcWpGtFbzsFz DvhFIa/0JdFuCK2aG9Vs48QbRdKKMdUWDkMLc5GV0KXCiWMsCJib5yQw7wDYh5/ybCdX 2kVpr4zSzznwFc2gjVLC7TKjCY0xSYv66YDh9JcRinJeZI6UAt6w9Fbe5UwTo8Pqyk7j /9dOiLhkhtQ9QFH1Wrbr75JW4H9tHOmWfBKRGTno3VaeUSd3t4hj7XAR/e5Pfbtl6vcr 5hRhYczGKEWsZ7YQsLylQaLOHcLSgrxtTJD/BV9r1VIYUF/2JB4+Snsf5ye6VMttuWse dArA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724237057; x=1724841857; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=zsXwwmVFE029w8OM4jI2xr8ALMyz0YfGcUY2KSYuOHI=; b=jzEPRlQ7UODMy3/bAQXfStU90ADeNskJ2RxL2emCMQaQlfrJMErT35MPAE5PisQ25I g+gE9HP5cOSTSDRT2spIq5b7VFFKfuF0apAvt109EkBfrcn4Nj6QgS9RNn7C+p3wPQeo /HsWperFnjSWRKEJa9nfOAeVx9YbkAN+OvOzv/sin4TvRJS+RIt3foHXZDYEWwFVFW+/ BWkQOhCwYvM+4qZuF7ANKg8I/O49eoI+HYzL5R4H1gwqF6pHjer6DGk0nSI1UVmzpljg TCxvqNOK7HHusKUQoV/LtpZKUeBCj+y6JIytwFvepqDQcHnvNrhxGEq8QAjzRfHFUcGv /9Mw==
X-Gm-Message-State: AOJu0YzOhKCjTqjN7dinXmuzJ8jEOJ1zPW2aBcg74kh3S5D82FD3gpwA 2CY6o3Hg6f73eQf/8dshRPMJ+z1LRHwgAlpZ+BZV7vyzDdQtOR1lB+D84A==
X-Google-Smtp-Source: AGHT+IFK86NYDa/gTIIqr4wqASJnOLtwohBFCNDMXSUjzPRwMAHhMlk/ScitcNqo0p1IjLgbq7hCXA==
X-Received: by 2002:a05:600c:1e24:b0:426:59d3:8cae with SMTP id 5b1f17b1804b1-42abd215528mr17619625e9.13.1724237056825; Wed, 21 Aug 2024 03:44:16 -0700 (PDT)
Received: from ?IPV6:2a01:e0a:e1b:64b0:8563:213:eece:478? ([2a01:e0a:e1b:64b0:8563:213:eece:478]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-3718983a184sm15305125f8f.14.2024.08.21.03.44.15 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 21 Aug 2024 03:44:16 -0700 (PDT)
Message-ID: <fcdf23a9-fb0f-48d2-b141-dce1d634b6d9@gmail.com>
Date: Wed, 21 Aug 2024 12:44:15 +0200
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
To: Carsten Bormann <cabo@tzi.org>
References: <17c394aa-095b-4a6d-95ee-0741b6b166f8@gmail.com> <2869DB6E-61BD-42D8-80B4-AA909C978B56@tzi.org>
Content-Language: en-US
From: Anders Rundgren <anders.rundgren.net@gmail.com>
In-Reply-To: <2869DB6E-61BD-42D8-80B4-AA909C978B56@tzi.org>
Content-Type: text/plain; charset="UTF-8"; format="flowed"
Content-Transfer-Encoding: 8bit
Message-ID-Hash: EP7EOJ33XIIETI7VKPKZTOB75GVYTINU
X-Message-ID-Hash: EP7EOJ33XIIETI7VKPKZTOB75GVYTINU
X-MailFrom: anders.rundgren.net@gmail.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: "cbor@ietf.org" <cbor@ietf.org>
X-Mailman-Version: 3.3.9rc4
Precedence: list
Subject: [Cbor] Re: Dealing with -0.0, NaN, and Infinity
List-Id: "Concise Binary Object Representation (CBOR)" <cbor.ietf.org>
Archived-At: <https://mailarchive.ietf.org/arch/msg/cbor/vHqLTqj1jIWWHqbva5YDFd0ySjY>
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>
On 2024-08-21 11:59, Carsten Bormann wrote: > On 2024-08-21, at 11:42, Anders Rundgren <anders.rundgren.net@gmail.com> wrote: >> >> When trying to define a subset of CBOR CDE suitable as a JSON replacement > > ➔ “a CDE application profile” (fixed that for you) Right but since the proposal is an API, there is no apparent need for a separate application profile: https://cyberphone.github.io/CBOR.js/doc/#main.wrappers In addition, given the lukewarm interest in this project and its objectives, where would such a profile be developed? > >> Although -0.0, NaN, and Infinity probably have very limited relevance in the intended target market, they must still be dealt with in some way. The easy way is of course to just ban them during decoding. > > Which an application profile can do in its set of exclusions. Sure. >> FWIW, these are my current suggestions: >> >> Following IEEE 754 rules it seems that -0.0 does not interfere with normal operations including comparisons; it is still treated as 0.0. So it is currently supported "as is". > > (The current text in CDE does not address decode-time reductions, as they don’t make sense for deterministic encoding — that must necessarily round-trip, so all reductions are encode-time.) In this particular case there is no reduction. -0.0 is supported as specified by CDE. >> However, since mathematical operations using NaN and Infinity are somewhat less nice, and typically indicate that something is fundamentally wrong, their support is currently made optional: https://cyberphone.github.io/CBOR.js/doc/#decoder.cbor.initextended > > I don’t know what “optional” means. You probably did not look into the supplied link. > Do you mean: > > https://www.ietf.org/archive/id/draft-ietf-cbor-cde-05.html#appendix-A-7 Probably not. For platform-wide solutions, run-time, per application options, is the only realistic way dealing with profiling of any kind. If you take a peek into https://cyberphone.github.io/CBOR.js/doc/#decoder.cbor.initextended you will find other options that may be needed. You'll find then in https://cbor.me as well :) >> NaN with payloads are always rejected. It is still a "strict subset" :) > > All NaNs have payloads. > I think you are talking about payloads that are non-zero. > You should probably also exclude negative NaNs, then. Yeah, the proposed API and associated encoding scheme only supports a single NaN variant. 0xfe00 to be more precise. > >> Related: since the JavaScript "JSON" object never became compatible with Open API number requirements, this became a core priority for "CBOR": https://cyberphone.github.io/CBOR.js/doc/#cbor.int.getint64 > > With a (presumably model-guided) pull-parser it is of course much easier to deal with the JavaScript number system. I don’t get the question here, though. There is no question, it just emphasizes how an ES "CBOR" object could be a better mousetrap than the current ES "JSON" object. It is called "marketing" :) Anders > > Grüße, Carsten >
- [Cbor] Dealing with -0.0, NaN, and Infinity Anders Rundgren
- [Cbor] Re: Dealing with -0.0, NaN, and Infinity Carsten Bormann
- [Cbor] Re: Dealing with -0.0, NaN, and Infinity Anders Rundgren
- [Cbor] Re: Dealing with -0.0, NaN, and Infinity Carsten Bormann
- [Cbor] Re: Dealing with -0.0, NaN, and Infinity Anders Rundgren
- [Cbor] Re: Dealing with -0.0, NaN, and Infinity Anders Rundgren