Re: [Cbor] dCBOR moving from numerically-typeless systems
Carsten Bormann <cabo@tzi.org> Sun, 12 March 2023 09:01 UTC
Return-Path: <cabo@tzi.org>
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 E7FD1C1516E0 for <cbor@ietfa.amsl.com>; Sun, 12 Mar 2023 01:01:16 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.489
X-Spam-Level:
X-Spam-Status: No, score=-1.489 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, KHOP_HELO_FCRDNS=0.399, RCVD_IN_ZEN_BLOCKED_OPENDNS=0.001, SPF_HELO_NONE=0.001, T_SPF_TEMPERROR=0.01] autolearn=no autolearn_force=no
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 3yALYI-wOurp for <cbor@ietfa.amsl.com>; Sun, 12 Mar 2023 01:01:12 -0800 (PST)
Received: from smtp.uni-bremen.de (mail.uni-bremen.de [134.102.50.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id D3180C1527AE for <cbor@ietf.org>; Sun, 12 Mar 2023 01:01:10 -0800 (PST)
Received: from smtpclient.apple (p548dc9a4.dip0.t-ipconnect.de [84.141.201.164]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.uni-bremen.de (Postfix) with ESMTPSA id 4PZDKb3DyPzDCbM; Sun, 12 Mar 2023 10:01:07 +0100 (CET)
Content-Type: text/plain; charset="utf-8"
Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3731.400.51.1.1\))
From: Carsten Bormann <cabo@tzi.org>
In-Reply-To: <2B1FA8CC-AD83-4E58-BE27-B6504F555694@wolfmcnally.com>
Date: Sun, 12 Mar 2023 10:00:54 +0100
Cc: cbor@ietf.org
Content-Transfer-Encoding: quoted-printable
Message-Id: <8551021E-A1A2-4764-B0DF-D3E7591EC9B6@tzi.org>
References: <2B1FA8CC-AD83-4E58-BE27-B6504F555694@wolfmcnally.com>
To: Wolf McNally <wolf@wolfmcnally.com>
X-Mailer: Apple Mail (2.3731.400.51.1.1)
Archived-At: <https://mailarchive.ietf.org/arch/msg/cbor/ZfF7KKHW6lyflDyLZ18oX3Ei5FU>
Subject: Re: [Cbor] dCBOR moving from numerically-typeless systems
X-BeenThere: cbor@ietf.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: "Concise Binary Object Representation \(CBOR\)" <cbor.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/cbor>, <mailto:cbor-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/cbor/>
List-Post: <mailto:cbor@ietf.org>
List-Help: <mailto:cbor-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/cbor>, <mailto:cbor-request@ietf.org?subject=subscribe>
X-List-Received-Date: Sun, 12 Mar 2023 09:01:17 -0000
Hi Wolf, (This is a nice specimen for what I call the fallacy of hand-crafted examples.) So it seems your data model is, say: a = [uint, 1.0..100.0, -14..68, float, float16] (I’m guessing from your example, using uint and int as well as a floating point range just to point out that there may be other application-level type requirements than int vs. float.) You already assume that, when extracting these values, you know the data model so you can hand the right type to the application (u64, f64, i8, f64, f16). So you might as well employ that information for encoding. You picked the example so that it actually has a benefit for the mixed integer/float encoding. But where your data model has floating point values, you are likely to have actual values all over the place, and the percentage of integral values (no fractional part) that you can represent as integers is low (depending on range — if you have a value from 1024.0 to 2047.0 with 10-bit precision, you are going to be more lucky of course :-), (but then there is no size difference in that particular range). If you are stuck with the JavaScript number system, you’ll want to represent the full-range uint in position 0 as a BigInt (see RFC 7493): you can’t just push all numbers into binary64 (float64), losing exactness. Again, I very much sympathize with the choices dCBOR makes (it was pretty much how I looked at things in 2013), I just wanted to point out where your hand-crafted example is missing out on additional considerations that just don’t pop up in that example, but do in my hand-crafted one :-). Grüße, Carsten
- [Cbor] dCBOR moving from numerically-typeless sys… Wolf McNally
- Re: [Cbor] dCBOR moving from numerically-typeless… Carsten Bormann
- Re: [Cbor] dCBOR moving from numerically-typeless… Wolf McNally
- Re: [Cbor] dCBOR moving from numerically-typeless… Carsten Bormann
- Re: [Cbor] dCBOR moving from numerically-typeless… Wolf McNally
- Re: [Cbor] dCBOR moving from numerically-typeless… Carsten Bormann
- Re: [Cbor] dCBOR moving from numerically-typeless… Wolf McNally
- Re: [Cbor] dCBOR moving from numerically-typeless… Carsten Bormann
- Re: [Cbor] dCBOR moving from numerically-typeless… Wolf McNally
- Re: [Cbor] dCBOR moving from numerically-typeless… Wolf McNally
- Re: [Cbor] dCBOR moving from numerically-typeless… Carsten Bormann
- Re: [Cbor] dCBOR moving from numerically-typeless… Wolf McNally