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

Christian Hopps <> Tue, 07 July 2020 11:53 UTC

Return-Path: <>
Received: from localhost (localhost []) by (Postfix) with ESMTP id 15ED03A0BD6 for <>; Tue, 7 Jul 2020 04:53:23 -0700 (PDT)
X-Virus-Scanned: amavisd-new at
X-Spam-Flag: NO
X-Spam-Score: -1.897
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 ([]) by localhost ( []) (amavisd-new, port 10024) with ESMTP id cASJePgCM9B1 for <>; Tue, 7 Jul 2020 04:53:21 -0700 (PDT)
Received: from ( []) by (Postfix) with ESMTP id 9A7703A0BD5 for <>; Tue, 7 Jul 2020 04:53:21 -0700 (PDT)
Received: from ( []) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by (Postfix) with ESMTPSA id 1BCFB60EC0; Tue, 7 Jul 2020 11:53:20 +0000 (UTC)
From: Christian Hopps <>
Message-Id: <>
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.\))
Date: Tue, 07 Jul 2020 07:53:19 -0400
In-Reply-To: <>
Cc: Christian Hopps <>, NetMod WG <>
To: Juergen Schoenwaelder <>
References: <> <>
X-Mailer: Apple Mail (2.3608.
Archived-At: <>
Subject: Re: [netmod] Justification for decimal64 over string for floating point values in geo location data?
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: NETMOD WG list <>
List-Unsubscribe: <>, <>
List-Archive: <>
List-Post: <>
List-Help: <>
List-Subscribe: <>, <>
X-List-Received-Date: Tue, 07 Jul 2020 11:53:23 -0000

> On Jul 7, 2020, at 7:24 AM, Juergen Schoenwaelder <> 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).


> /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 ( 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
> --
> Juergen Schoenwaelder           Jacobs University Bremen gGmbH
> Phone: +49 421 200 3587         Campus Ring 1 | 28759 Bremen | Germany
> Fax:   +49 421 200 3103         <>