Skip to content

Commit

Permalink
Cleaned up phrasing around floating point numbers.
Browse files Browse the repository at this point in the history
  • Loading branch information
janderland committed Nov 18, 2024
1 parent 49206be commit f6ea8d4
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 33 deletions.
35 changes: 20 additions & 15 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,16 @@ <h1 id="data-elements">Data Elements</h1>
</div>
<p>The <code>nil</code> type may only be instantiated as the element
<code>nil</code>. The <code>int</code> type may be instantiated as any
arbitrarily large integer. The <code>num</code> type may be
instantiated as any 64-bit floating point number.</p>
<pre><code>/val(9223372036854775808)=2.284</code></pre>
arbitrarily large integer.</p>
<pre><code>/val(9223372036854775808)=nil</code></pre>
<p>The <code>num</code> type may be instantiated as any real number
between <code>-1.18e4932</code> and <code>1.18e4932</code>. The
element is represented as an 80-bit <a
href="https://en.wikipedia.org/wiki/Extended_precision#x86_extended_precision_format">extended
double floating-point</a> and will snap to the nearest representable
number. The <code>num</code> type may also be instantiated as
<code>-inf</code>, <code>inf</code>, <code>-nan</code>, and
<code>nan</code>, as is allowed by it’s binary format.</p>
<p>The <code>str</code> type is the only element type allowed in
directory paths. If a directory string only contains alphanumericals,
underscores, dashes, and periods then the quotes may not be
Expand All @@ -187,19 +194,12 @@ <h1 id="data-elements">Data Elements</h1>
<pre class="language-fql query"><code>/region/north_america(22.3,-8)=(&quot;rain&quot;,&quot;fog&quot;)
/region/east_asia(&quot;japan&quot;,(&quot;sub&quot;,nil))=0xff</code></pre>
<h1 id="value-encoding">Value Encoding</h1>
<p>The tuple layer supports a unique encoding for <code>nil</code>,
but as a value <code>nil</code> is equivalent to an empty byte array.
This makes the following two queries equivalent.</p>
<pre class="language-fql query"><code>/entry(537856)=nil
/entry(537856)=0x</code></pre>
<p>The directory and tuple layers are responsible for encoding the
data elements in the key. As for the value, Foundation DB doesn’t
provide a standard encoding.</p>
<p>FQL provides value encodings for each of the data elements. A
particular encoding can be specified by modifying a data element or
type using options. When not specified, the element’s default encoding
is used. Below, you can see the supported valued encoding for each
type of data element.</p>
<p>FQL provides value encodings for each of the data elements. Some
elements have more than one value encoding. The default encoding for
each type is shown below.</p>
<div>
<table>
<thead>
Expand All @@ -211,7 +211,7 @@ <h1 id="value-encoding">Value Encoding</h1>
<tbody>
<tr>
<td style="text-align: left;"><code>nil</code></td>
<td style="text-align: left;">empty value</td>
<td style="text-align: left;">empty byte array</td>
</tr>
<tr>
<td style="text-align: left;"><code>bool</code></td>
Expand All @@ -228,7 +228,7 @@ <h1 id="value-encoding">Value Encoding</h1>
</tr>
<tr>
<td style="text-align: left;"><code>str</code></td>
<td style="text-align: left;">Unicode</td>
<td style="text-align: left;">UTF-8</td>
</tr>
<tr>
<td style="text-align: left;"><code>uuid</code></td>
Expand All @@ -245,6 +245,11 @@ <h1 id="value-encoding">Value Encoding</h1>
</tbody>
</table>
</div>
<p>The tuple layer supports a unique encoding for <code>nil</code>,
but as a value <code>nil</code> is equivalent to an empty byte array.
This makes the following two queries equivalent.</p>
<pre class="language-fql query"><code>/entry(537856)=nil
/entry(537856)=0x</code></pre>
<h1 id="holes-schemas">Holes &amp; Schemas</h1>
<p>A hole is any of the following syntax constructs: variables,
references, and the <code>...</code> token. Holes are used to define a
Expand Down
41 changes: 23 additions & 18 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,20 @@ layer](https://github.com/apple/foundationdb/blob/main/design/tuple.md).

The `nil` type may only be instantiated as the element
`nil`. The `int` type may be instantiated as any arbitrarily
large integer. The `num` type may be instantiated as any
64-bit floating point number.
large integer.

```
/val(9223372036854775808)=2.284
/val(9223372036854775808)=nil
```

The `num` type may be instantiated as any real number
between `-1.18e4932` and `1.18e4932`. The element is
represented as an 80-bit [extended double
floating-point](https://en.wikipedia.org/wiki/Extended_precision#x86_extended_precision_format)
and will snap to the nearest representable number. The `num`
type may also be instantiated as `-inf`, `inf`, `-nan`, and
`nan`, as is allowed by it's binary format.

The `str` type is the only element type allowed in directory
paths. If a directory string only contains alphanumericals,
underscores, dashes, and periods then the quotes may not be
Expand Down Expand Up @@ -184,40 +191,38 @@ contain any of the data elements.

# Value Encoding

The tuple layer supports a unique encoding for `nil`,
but as a value `nil` is equivalent to an empty byte array.
This makes the following two queries equivalent.

```language-fql {.query}
/entry(537856)=nil
/entry(537856)=0x
```

The directory and tuple layers are responsible for encoding
the data elements in the key. As for the value, Foundation
DB doesn't provide a standard encoding.

FQL provides value encodings for each of the data elements.
A particular encoding can be specified by modifying a data
element or type using options. When not specified, the
element's default encoding is used. Below, you can see the
supported valued encoding for each type of data element.
Some elements have more than one value encoding. The default
encoding for each type is shown below.

<div>

| Type | Encoding |
|:--------|:--------------------------------|
| `nil` | empty value |
| `nil` | empty byte array |
| `bool` | single byte, `0x00` means false |
| `int` | 64-bit, 1's compliment |
| `num` | IEEE 754 |
| `str` | Unicode |
| `str` | UTF-8 |
| `uuid` | RFC 4122 |
| `bytes` | as provided |
| `tup` | tuple layer |

</div>

The tuple layer supports a unique encoding for `nil`, but as
a value `nil` is equivalent to an empty byte array. This
makes the following two queries equivalent.

```language-fql {.query}
/entry(537856)=nil
/entry(537856)=0x
```

# Holes & Schemas

A hole is any of the following syntax constructs: variables,
Expand Down
4 changes: 4 additions & 0 deletions docs/js/fql.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@
beginKeywords: [
'true',
'false',
'-inf',
'inf',
'-nan',
'nan',
'clear',
'nil',
'any',
Expand Down

0 comments on commit f6ea8d4

Please sign in to comment.