Re: [netmod] Justification for decimal64 over string for floating point values in geo location data?

Christian Hopps <chopps@chopps.org> Tue, 07 July 2020 11:53 UTC

Return-Path: <chopps@chopps.org>
X-Original-To: netmod@ietfa.amsl.com
Delivered-To: netmod@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 15ED03A0BD6 for <netmod@ietfa.amsl.com>; Tue, 7 Jul 2020 04:53:23 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.897
X-Spam-Level:
X-Spam-Status: No, score=-1.897 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_NONE=0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
Received: from mail.ietf.org ([4.31.198.44]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id cASJePgCM9B1 for <netmod@ietfa.amsl.com>; Tue, 7 Jul 2020 04:53:21 -0700 (PDT)
Received: from smtp.chopps.org (smtp.chopps.org [54.88.81.56]) by ietfa.amsl.com (Postfix) with ESMTP id 9A7703A0BD5 for <netmod@ietf.org>; Tue, 7 Jul 2020 04:53:21 -0700 (PDT)
Received: from stubbs.int.chopps.org (047-050-069-038.biz.spectrum.com [47.50.69.38]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by smtp.chopps.org (Postfix) with ESMTPSA id 1BCFB60EC0; Tue, 7 Jul 2020 11:53:20 +0000 (UTC)
From: Christian Hopps <chopps@chopps.org>
Message-Id: <C77ED032-788C-410C-A239-86286ADE4E4A@chopps.org>
Content-Type: multipart/signed; boundary="Apple-Mail=_F7043008-35CE-4D43-86B4-27B5373681B9"; protocol="application/pgp-signature"; micalg="pgp-sha512"
Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\))
Date: Tue, 07 Jul 2020 07:53:19 -0400
In-Reply-To: <20200707112450.wrttuprwrdr3nl5i@anna.jacobs.jacobs-university.de>
Cc: Christian Hopps <chopps@chopps.org>, NetMod WG <netmod@ietf.org>
To: Juergen Schoenwaelder <j.schoenwaelder@jacobs-university.de>
References: <B548C4B4-2A97-4736-A6B2-358D1491D125@chopps.org> <20200707112450.wrttuprwrdr3nl5i@anna.jacobs.jacobs-university.de>
X-Mailer: Apple Mail (2.3608.80.23.2.2)
Archived-At: <https://mailarchive.ietf.org/arch/msg/netmod/T_5EoTh2iC9riS2XaaeF-wzSPqY>
Subject: Re: [netmod] Justification for decimal64 over string for floating point values in geo location data?
X-BeenThere: netmod@ietf.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: NETMOD WG list <netmod.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/netmod>, <mailto:netmod-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/netmod/>
List-Post: <mailto:netmod@ietf.org>
List-Help: <mailto:netmod-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/netmod>, <mailto:netmod-request@ietf.org?subject=subscribe>
X-List-Received-Date: Tue, 07 Jul 2020 11:53:23 -0000


> On Jul 7, 2020, at 7:24 AM, Juergen Schoenwaelder <j.schoenwaelder@jacobs-university.de> wrote:
> 
> Precision often means different things to different people. Here is my
> take:
> 
> - Floating point numbers have almost always rounding errors. And
>  floating point numbers use binary fractions, a decimal fraction like
>  1.0 has no precise representation as a binary fraction. Type 0.1 +
>  0.2 into python or haskell or any other language that gives you bare
>  floating point numbers and enjoy the result.
> 
> - Fixed precision decimal numbers do not have rounding errors since
>  they are essentially scaled integers and hence they are precise as
>  long as calculations stay within the range.
> 
> - Floating point numbers can cover a large number space (from very
>  tiny to really big), fixed precision decimal numbers are much more
>  restrictive.
> 
> - In XML and JSON, numbers are rendered in strings that likely do not
>  look much different if its a decimal64 or a float or ... If you really
>  care about size, use a binary encoding like CBOR.

So do you think it's enough to just use decimal64, and not justify it's use over strings? I don't necessarily think we need to talk to it in the document, but it was raised in the review so I figured some discussion on the list was at least merited.

While I haven't done any binary stuff with YANG, I think it's definitely usable that way (e.g., to define binary APIs in software where you probably wouldn't want to be using XML or JSON).

Thanks,
Chris.


> 
> /js
> 
> On Tue, Jul 07, 2020 at 07:06:20AM -0400, Christian Hopps wrote:
>> I received feedback in my YANG doctor review (thanks Mahesh) regarding the use of decimal64 for most of the values in the geo location grouping (https://tools.ietf.org/html/draft-ietf-netmod-geo-location-04). In my comparison sections I note that some precision (at the very extremes) may be lost when converting from other geo location formats that use string (or double for w3c) to decimal64. Given that mention of loss of extreme precision, the reviewer was asking if some justification for the decimal64 should be given in the document.
>> 
>> What are the advantages to using decimal64 for floating point numbers vs using a string with a pattern "[0-9]+(\.[0-9]+)?" (convert that to yang pattern language). The advantage of using a string is that the precision of the value is not restricted by the model. Does the YANG decimal64 values have a concise binary format that can be more efficiently transported or stored in binary form? If so is this the only advantage, and is it enough of one to limit the precision in the model?
>> 
>> It's definitely worth noting that the precision of the decimal64 values seem vastly adequate for geo location data (e.g., for Cartesian coordinates and height values which are measured in meters the fractional digits is 6 which means the surface could be up to 9 billion kilometers large (or away from for height) and the precision is to the micrometer. For ellipsoidal coordinates there are 12 fractional digits for the degrees.
>> 
>> Thanks,
>> Chris.
> 
> 
> 
>> _______________________________________________
>> netmod mailing list
>> netmod@ietf.org
>> https://www.ietf.org/mailman/listinfo/netmod
> 
> 
> --
> Juergen Schoenwaelder           Jacobs University Bremen gGmbH
> Phone: +49 421 200 3587         Campus Ring 1 | 28759 Bremen | Germany
> Fax:   +49 421 200 3103         <https://www.jacobs-university.de/>
>