Subject: [Cellar] patch on textual expressions of floats in EBML Schema

From: Dave Rice <[email-masked]>
Date: Sun, 17 Apr 2016 09:16:13 -0400

Hi all,
Here’s my patch to add a small section on the textual representation of floats in EBML Schemas (this would be relevant when a ‘range’ or ‘default’ value is declared for an EBML Float Element.  I’m not exactly sure my examples are correct, please review.

There’s a few issues with parsing Hexadecimal Floating-Point Constants in a range. For instance, with integers the hyphen is the delimiter between the maximum and minimum value of the range but hyphen may also be used within a Hexadecimal Floating-Point Constants to express a negative binary power. For instance in a range like this the hyphens have two meanings: 0x1p-8-0x1p-2.

I cited http://www.exploringbinary.com/hexadecimal-floating-point-constants/ as the definition of Hexadecimal Floating-Point Constants rather than redefine Hexadecimal Floating-Point Constants within the EBML spec. Is there a more official citation for Hexadecimal Floating-Point Constants?

The patch includes line updates to “Expression of range” but this is only to include float as an option. Mostly it’s the "#### Textual expression of Floats” section in need of review. The patch may be seen in a GitHub context here: https://github.com/MediaArea/ebml-specification/commit/a3dc4c2e3128048e991a3fa0907d501654383ae7.

From 880936692e37b3bdd0e8ec57332278491e5e470b Mon Sep 17 00:00:00 2001
From: dericed <[email-masked]>
Date: Sun, 17 Apr 2016 09:05:24 -0400
Subject: [PATCH] define textual expression of floats in ebml schema

---
 specification.markdown | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/specification.markdown b/specification.markdown
index cc39012..ea78cfe 100644
--- a/specification.markdown
+++ b/specification.markdown
@@ -271,13 +271,23 @@ An Identically-Recurring Element is an Element that may occur within its Parent
 
 #### Expression of range
 
-The `range` attribute MUST only be used with EBML Elements that are either `signed integer` or `unsigned integer`. The `range` attribute does not support date or float EBML Elements. The `range` expression may contain whitespace for readability but whitespace within a `range` expression MUST NOT convey meaning. The expression of the `range` MUST adhere to one of the following forms:
+The `range` attribute MUST only be used with EBML Elements that are either `signed integer`, `unsigned integer`, or `float`. The `range` attribute does not support date EBML Elements. The `range` expression may contain whitespace for readability but whitespace within a `range` expression MUST NOT convey meaning. The expression of the `range` MUST adhere to one of the following forms:
 
-    - `x-y` where x and y are integers and `y` must be greater than `x`, meaning that the value must be greater than or equal to `x` and less than or equal to `y`.
-    - `>x` where `x` is an integer, meaning that the value MUST be greater than `x`.
-    - `x` where `x` is an integer, meaning that the value MUST be equal `x`.
+    - `x-y` where x and y are integers or floats and `y` must be greater than `x`, meaning that the value must be greater than or equal to `x` and less than or equal to `y`.
+    - `>x` where `x` is an integer or float, meaning that the value MUST be greater than `x`.
+    - `x` where `x` is an integer or float, meaning that the value MUST be equal `x`.
 
-The `range` may use the prefix `not ` to indicate that the expressed range is negated.
+The `range` may use the prefix `not ` to indicate that the expressed range is negated. Please also see the section on [textual expression of floats](#textual-expression-of-floats).
+
+#### Textual expression of Floats
+
+When a float must be represented textually, such as within a `default` or `range` value of an EBML Schema, the expression of `range` for a float Element MUST represent the float range as a [Hexadecimal Floating-Point Constants](http://www.exploringbinary.com/hexadecimal-floating-point-constants/). The following table provides examples of expressions of float ranges.
+
+| as decimal  | as Hexadecimal Floating-Point Constants | 
+|-------------|-----------------------------------------|
+| 0.0-1.0     | 0x0p+1-0x1p+0                           |
+| 1.0-256.0   | 0x1p+0-0x1p+8                           |
+| 0.857421875 | 0x1.b7p-1                               |
 
 #### Note on the Use of default attributes to define Mandatory EBML Elements
 
-- 
2.8.1

Best Regards,
Dave Rice

---

From: Nithin Mathew Kurien <[email-masked]>
Date: Mon, 18 Apr 2016 20:30:32 +0530

Hi,

On Sun, Apr 17, 2016 at 6:46 PM, Dave Rice <[email-masked]> wrote:

> Hi all,
> Here’s my patch to add a small section on the textual representation of
> floats in EBML Schemas (this would be relevant when a ‘range’ or ‘default’
> value is declared for an EBML Float Element.  I’m not exactly sure my
> examples are correct, please review.
>
> There’s a few issues with parsing Hexadecimal Floating-Point Constants in
> a range. For instance, with integers the hyphen is the delimiter between
> the maximum and minimum value of the range but hyphen may also be used
> within a Hexadecimal Floating-Point Constants to express a negative
> binary power. For instance in a range like this the hyphens have two
> meanings: 0x1p-8-0x1p-2.
>
> I think the parser can resolve this issue without much trouble. In this
context, the hyphen expresses a negative binary power, when it is preceded
by a 'P' or 'p'. On the other hand, the hyphen serves as the delimiter
between the minimum and maximum values, when it is not preceded by a 'P' or
'p'. This criterion can be used to distinguish the two cases.

I cited http://www.exploringbinary.com/hexadecimal-floating-point-constants/
> as the definition of Hexadecimal Floating-Point Constants rather than
> redefine Hexadecimal Floating-Point Constants within the EBML spec. Is
> there a more official citation for Hexadecimal Floating-Point Constants?
>
> The official citation is the C11 standard (ISO/IEC 9899:2011); but the
document is available only for a fee from the ISO website. A publicly
available draft is http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf.
The relevant section is 6.4.4.2 Floating constants (pages 65-66).

> The patch includes line updates to “Expression of range” but this is only
> to include float as an option. Mostly it’s the "#### Textual expression of
> Floats” section in need of review. The patch may be seen in a GitHub
> context here:
> https://github.com/MediaArea/ebml-specification/commit/a3dc4c2e3128048e991a3fa0907d501654383ae7
> .
>
>
> -The `range` attribute MUST only be used with EBML Elements that are
> either `signed integer` or `unsigned integer`. The `range` attribute does
> not support date or float EBML Elements. The `range` expression may contain
> whitespace for readability but whitespace within a `range` expression MUST
> NOT convey meaning. The expression of the `range` MUST adhere to one of the
> following forms:
> +The `range` attribute MUST only be used with EBML Elements that are
> either `signed integer`, `unsigned integer`, or `float`. The `range`
> attribute does not support date EBML Elements. The `range` expression may
> contain whitespace for readability but whitespace within a `range`
> expression MUST NOT convey meaning. The expression of the `range` MUST
> adhere to one of the following forms:
>
> In this context, does 'float' mean only 32-bit floats, or does it mean
both 32-bit floats and 64-bit doubles? If it is the latter, then I think
'floating constant' (given in the C11 standard) may be a more unambiguous
term.

-    - `x-y` where x and y are integers and `y` must be greater than `x`,
> meaning that the value must be greater than or equal to `x` and less than
> or equal to `y`.
> +    - `x-y` where x and y are integers or floats and `y` must be greater
> than `x`, meaning that the value must be greater than or equal to `x` and
> less than or equal to `y`.
> +The `range` may use the prefix `not ` to indicate that the expressed
> range is negated. Please also see the section on [textual expression of
> floats](#textual-expression-of-floats).
> +
> +When a float must be represented textually, such as within a `default` or
> `range` value of an EBML Schema, the expression of `range` for a float
> Element MUST represent the float range as a [Hexadecimal Floating-Point
> Constants](
> http://www.exploringbinary.com/hexadecimal-floating-point-constants/).
> The following table provides examples of expressions of float ranges.
> +
The table is correct regarding the representation of the constants. Maybe
we can also include an example containing negative floating constants like
this one:

-1.0--0.857421875               -0x1p+0--0x1.b7p-1

 #### Note on the Use of default attributes to define Mandatory EBML
> Elements

Thanks and regards,
Nithin

---

From: Moritz Bunkus <[email-masked]>
Date: Mon, 18 Apr 2016 17:57:07 +0200

Hey,

> 'p'. This criterion can be used to distinguish the two cases.

I agree. If a p occurs the following element must be the
exponent. Therefore there's no ambiguity.

> 'floating constant' (given in the C11 standard) may be a more unambiguous

The specs always talk about the numerical types as they apply to EBML
(section "EBML Element Types" at [1]). We don't talk about data types in
a specific programming language; that's an implementation detail the
specs shouldn't care about. So "float" means up to 64bits, just as
"unsigned integer" does. We don't say "uint64_t" there either.

Kind regards,
mosu

[1]  https://github.com/Matroska-Org/ebml-specification/blob/master/specification.markdown

---

From: Dave Rice <[email-masked]>
Date: Mon, 18 Apr 2016 12:00:54 -0400

> On Apr 18, 2016, at 11:57 AM, Moritz Bunkus <[email-masked]> wrote:
> 
> Hey,
> 

Regarding such interpretation, currently specdata.xml expresses float range in a style of "0.0-1.0". Should we say that both forms are valid as ranges? Or that "0x0p+1-0x1p+0" is valid but "0.0-1.0" is invalid.

> _______________________________________________
> Cellar mailing list
> [email-masked]
> https://www.ietf.org/mailman/listinfo/cellar

---

From: Dave Rice <[email-masked]>
Date: Sat, 23 Apr 2016 19:33:01 -0400

Here's an updated patch for float ranges in EBML Schema that incorporates Nithin's advice.

A pull request is here: https://github.com/Matroska-Org/ebml-specification/pull/61

From cbe07820fe85ed0aa4c591727cdc9f88a2339e11 Mon Sep 17 00:00:00 2001
From: dericed <[email-masked]>
Date: Sun, 17 Apr 2016 09:05:24 -0400
Subject: [PATCH] define textual expression of floats in ebml schema

---
 specification.markdown | 23 ++++++++++++++++++-----
 1 file changed, 18 insertions(+), 5 deletions(-)

diff --git a/specification.markdown b/specification.markdown
index cc39012..3f262b9 100644
--- a/specification.markdown
+++ b/specification.markdown
@@ -271,13 +271,26 @@ An Identically-Recurring Element is an Element that may occur within its Parent
 
 #### Expression of range

 
-The `range` may use the prefix `not ` to indicate that the expressed range is negated.
+The `range` may use the prefix `not ` to indicate that the expressed range is negated. Please also see the section on [textual expression of floats](#textual-expression-of-floats).
+
+#### Textual expression of Floats
+
+When a float value is represented textually in an EBML Schema, such as within a `default` or `range` value, the float values MUST be expressed as a Hexadecimal Floating-Point Constants as defined in the C11 standard [ISO/IEC 9899:2011](http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf) (see section 6.4.4.2 on Floating Constants). The following table provides examples of expressions of float ranges.
+
+| as decimal        | as Hexadecimal Floating-Point Constants | 
+|-------------------|-----------------------------------------|
+| 0.0-1.0           | 0x0p+1-0x1p+0                           |
+| 1.0-256.0         | 0x1p+0-0x1p+8                           |
+| 0.857421875       | 0x1.b7p-1                               |
+| -1.0--0.857421875 | -0x1p+0--0x1.b7p-1                      |
+
+Within an expression of a float range, as in an integer range, the `-` (hyphen) character is the separator between the minimal and maximum value permitted by the range. Note that Hexadecimal Floating-Point Constants also use a `-` (hyphen) when indicating a negative binary power. Within a float range, when a `-` (hyphen) is immediately preceded by a letter `p`, then the `-` (hyphen) is a part of the Hexadecimal Floating-Point Constant which notes negative binary power. Within a float range, when a `-` (hyphen) is immediately preceded by a letter `p`, then the `-` (hyphen) represents the separator between the minimal and maximum value permitted by the range.

-- 
2.8.0