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

David Spakes <spakes@snmp.com> Tue, 07 July 2020 14:40 UTC

Return-Path: <spakes@snmp.com>
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 B4A583A0D4B for <netmod@ietfa.amsl.com>; Tue, 7 Jul 2020 07:40:45 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.9
X-Spam-Level:
X-Spam-Status: No, score=-1.9 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, SPF_PASS=-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 oPlWIjCkJlAT for <netmod@ietfa.amsl.com>; Tue, 7 Jul 2020 07:40:43 -0700 (PDT)
Received: from mailbox.SNMP.COM (mailbox.snmp.com [192.147.142.80]) by ietfa.amsl.com (Postfix) with ESMTP id C7CFB3A0D4A for <netmod@ietf.org>; Tue, 7 Jul 2020 07:40:42 -0700 (PDT)
Received: from mainfs.snmp.com (mainfs.snmp.com [192.147.142.124]) by mailbox.SNMP.COM (8.9.3p2-20030922/m.0080228) with ESMTP id KAA01069; Tue, 7 Jul 2020 10:40:40 -0400 (EDT)
Received: from mainfs.snmp.com (localhost [127.0.0.1]) by mainfs.snmp.com (8.14.5/8.14.5) with ESMTP id 067Eeehe053763; Tue, 7 Jul 2020 10:40:40 -0400 (EDT) (envelope-from spakes@snmp.com)
Received: from localhost (spakes@localhost) by mainfs.snmp.com (8.14.5/8.14.5/Submit) with ESMTP id 067Eed6a053760; Tue, 7 Jul 2020 10:40:39 -0400 (EDT) (envelope-from spakes@snmp.com)
X-Authentication-Warning: mainfs.snmp.com: spakes owned process doing -bs
Date: Tue, 07 Jul 2020 10:40:39 -0400
From: David Spakes <spakes@snmp.com>
To: netmod@ietf.org
In-Reply-To: <85c0def4-b82a-d58a-0694-05fd6df90bcc@nic.cz>
Message-ID: <alpine.BSF.2.00.2007071025350.23266@mainfs.snmp.com>
References: <B548C4B4-2A97-4736-A6B2-358D1491D125@chopps.org> <20200707112450.wrttuprwrdr3nl5i@anna.jacobs.jacobs-university.de> <85c0def4-b82a-d58a-0694-05fd6df90bcc@nic.cz>
User-Agent: Alpine 2.00 (BSF 1167 2008-08-23)
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset="US-ASCII"; format="flowed"
Archived-At: <https://mailarchive.ietf.org/arch/msg/netmod/h5jOHLgP-r9gm39iRtaitS-VaZg>
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 14:40:46 -0000

Like Lada, I know nothing about geo-location formats.  But this
discussion sounds familiar because it keeps coming up time and
again.  There are arguments for and against decimal64, and people
have before expressed a need for a variable-precision type.

I proposed the following compromise/solution in 2009 and again in 2014.
Now, I'll propose it again: a derived type that solidifies the
position/preservation of decimal64 and builds on it to deliver the
desired feature.


    typedef real {
      type union {
        type decimal64 {
          fraction-digits 18;
          range "-0.999999999999999999 .. 0.999999999999999999";
        }
        type decimal64 {
          fraction-digits 17;
          range "-9.99999999999999999 .. 9.99999999999999999";
        }
        type decimal64 {
          fraction-digits 16;
          range "-99.9999999999999999 .. 99.9999999999999999";
        }
        type decimal64 {
          fraction-digits 15;
          range "-999.999999999999999 .. 999.999999999999999";
        }
        type decimal64 {
          fraction-digits 14;
          range "-9999.99999999999999 .. 9999.99999999999999";
        }
        type decimal64 {
          fraction-digits 13;
          range "-99999.9999999999999 .. 99999.9999999999999";
        }
        type decimal64 {
          fraction-digits 12;
          range "-999999.999999999999 .. 999999.999999999999";
        }
        type decimal64 {
          fraction-digits 11;
          range "-9999999.99999999999 .. 9999999.99999999999";
        }
        type decimal64 {
          fraction-digits 10;
          range "-99999999.9999999999 .. 99999999.9999999999";
        }
        type decimal64 {
          fraction-digits 9;
          range "-999999999.999999999 .. 999999999.999999999";
        }
        type decimal64 {
          fraction-digits 8;
          range "-9999999999.99999999 .. 9999999999.99999999";
        }
        type decimal64 {
          fraction-digits 7;
          range "-99999999999.9999999 .. 99999999999.9999999";
        }
        type decimal64 {
          fraction-digits 6;
          range "-999999999999.999999 .. 999999999999.999999";
        }
        type decimal64 {
          fraction-digits 5;
          range "-9999999999999.99999 .. 9999999999999.99999";
        }
        type decimal64 {
          fraction-digits 4;
          range "-99999999999999.9999 .. 99999999999999.9999";
        }
        type decimal64 {
          fraction-digits 3;
          range "-999999999999999.999 .. 999999999999999.999";
        }
        type decimal64 {
          fraction-digits 2;
          range "-9999999999999999.99 .. 9999999999999999.99";
        }
        type decimal64 {
          fraction-digits 1;
          range "-99999999999999999.9 .. 99999999999999999.9";
        }
        type enumeration {
          enum overflow;
          enum underflow;
        }
      }
      description
        "The real type defines a large, finite set of real numbers with
         varying degrees of magnitude and precision.  An object of type
         real is able to express configuration and state data as any of
         the real numbers in the set.  The real type is suitable for
         applications that deal with ratios in which the decimal point is
         not fixed to a single position.

         Positive numbers larger than 99999999999999999.9 in state data
         SHALL be represented as an overflow.  The enumerated value
         overflow is not valid for an <edit-config> operation.

         Negative numbers larger than -99999999999999999.9 in state data
         SHALL be represented as an underflow.  The enumerated value
         underflow is not valid for an <edit-config> operation.

         Real numbers between -99999999999999999.9 and 99999999999999999.9
         (inclusive) having a combination of magnitude and precision that
         falls outside of one of the range substatements in the union--
         including irrational numbers such as 'pi'--may only be
         represented by the real type through rounding or truncation.
         For example, pi could be rounded (up) to 3.14159265358979324 or
         truncated to 3.14159265358979323 to preserve as much of the
         precision information as possible.  Note that an application
         could choose to round (down) the value of pi to 3.14 or truncate
         the value of pi to 3.14.  This specification does not define
         rules for the rounding or truncating of such values, considering
         these decisions to be application-specific.";
    }



David Spakes



On Tue, Jul 07, 2020 at 08:27:19AM -0400, Christian Hopps wrote:

> Mentioned in the earlier mail
>
> instead of
>
>     "decimal64"
>
> use
>
>     "type string { pattern '[0-9]+(\.[0-9]+)?'; }"
>


On Tue, 7 Jul 2020, Ladislav Lhotka wrote:

> On 07. 07. 20 13:24, 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.
>
> I know nothing about geo-location formats, but I suspect that the string
> representation is based on some assumptions regarding the underlying
> numeric type. So one option might be to define a new type derived from
> "string", and specify these assumptions in the description.
>
> Lada
>
> -- 
> Ladislav Lhotka
> Head, CZ.NIC Labs
> PGP Key ID: 0xB8F92B08A9F76C67


-------------------------------------------------------------
  David Spakes                       email:   spakes@snmp.com
  SNMP Research                      voice:   +1 865 573 1434
  3001 Kimberlin Heights Road          fax:   +1 865 573 9197
  Knoxville, TN  37920-9716  USA      http://www.snmp.com
-------------------------------------------------------------