Add fixed-length floating point number support
[normand.git] / README.adoc
index 72c2f82b8e61890162af90d4f65d7fd798f7e51a..44e62c513f90f599a86a4d58335974fdfb4fa24b 100644 (file)
@@ -29,7 +29,7 @@ _**Normand**_ is a text-to-binary processor with its own language.
 This package offers both a portable {py3} module and a command-line
 tool.
 
-WARNING: This version of Normand is 0.5, meaning both the Normand
+WARNING: This version of Normand is 0.6, meaning both the Normand
 language and the module/CLI interface aren't stable.
 
 ifdef::env-github[]
@@ -133,7 +133,7 @@ Variables::
 The value of a variable assignment is the evaluation of a valid {py3}
 expression which may include label and variable names.
 
-Fixed-length integer with a given length (8{nbsp}bits to 64{nbsp}bits) and byte order::
+Fixed-length number with a given length (8{nbsp}bits to 64{nbsp}bits) and byte order::
 +
 Input:
 +
@@ -141,15 +141,17 @@ Input:
 {strength = 4}
 {be} 67 <lbl> 44 $178 {(end - lbl) * 8 + strength : 16} $99 <end>
 {le} {-1993 : 32}
+{-3.141593 : 64}
 ----
 +
 Output:
 +
 ----
-67 44 b2 00 2c 63 37 f8  ff ff
+67 44 b2 00 2c 63 37 f8  ff ff 7f bd c2 82 fb 21
+09 c0
 ----
 +
-The encoded integer is the evaluation of a valid {py3} expression which
+The encoded number is the evaluation of a valid {py3} expression which
 may include label and variable names.
 
 https://en.wikipedia.org/wiki/LEB128[LEB128] integer::
@@ -276,8 +278,8 @@ current state:
 |[[cur-offset]] Current offset
 |
 The current offset has an effect on the value of <<label,labels>> and of
-the special `ICITTE` name in <<fixed-length-integer,fixed-length
-integer>>, <<leb-128-integer,LEB128 integer>>, and
+the special `ICITTE` name in <<fixed-length-number,fixed-length
+number>>, <<leb-128-integer,LEB128 integer>>, and
 <<variable-assignment,variable assignment>> expression evaluation.
 
 Each generated byte increments the current offset.
@@ -290,7 +292,7 @@ current offset.
 |[[cur-bo]] Current byte order
 |
 The current byte order has an effect on the encoding of
-<<fixed-length-integer,fixed-length integers>>.
+<<fixed-length-number,fixed-length numbers>>.
 
 A <<current-byte-order-setting,current byte order setting>> may change
 the current byte order.
@@ -318,9 +320,9 @@ The available items are:
 * A <<current-byte-order-setting,current byte order setting>> (big or
   little endian).
 
-* A <<fixed-length-integer,fixed-length integer>> using the
-  <<cur-bo,current byte order>> and of which the value is the result of
-  a {py3} expression.
+* A <<fixed-length-number,fixed-length number>> (integer or
+  floating point) using the <<cur-bo,current byte order>> and of which
+  the value is the result of a {py3} expression.
 
 * An <<leb128-integer,LEB128 integer>> of which the value is the result
   of a {py3} expression.
@@ -556,31 +558,49 @@ The two accepted forms are:
 ``pass:[{be}]``:: Set the current byte order to big endian.
 ``pass:[{le}]``:: Set the current byte order to little endian.
 
-=== Fixed-length integer
+=== Fixed-length number
 
-A _fixed-length integer_ represents a fixed number of bytes encoding an
-unsigned or signed integer which is the result of evaluating a {py3}
-expression using the <<cur-bo,current byte order>>.
+A _fixed-length number_ represents a fixed number of bytes encoding
+either:
+
+* An unsigned or signed integer (two's complement).
++
+The available lengths are 8, 16, 24, 32, 40, 48, 56, and 64.
+
+* A floating point number
+  ([IEEE{nbsp}754-2008[https://standards.ieee.org/standard/754-2008.html]).
++
+The available length are 32 (_binary32_) and 64 (_binary64_).
 
-A fixed-length integer is:
+The value is the result of evaluating a {py3} expression using the
+<<cur-bo,current byte order>>.
+
+A fixed-length number is:
 
 . The ``pass:[{]`` prefix.
 
 . A valid {py3} expression.
 +
-For a fixed-length integer at some source location{nbsp}__**L**__, this
+For a fixed-length number at some source location{nbsp}__**L**__, this
 expression may contain the name of any accessible <<label,label>> (not
 within a nested group), including the name of a label defined
 after{nbsp}__**L**__, as well as the name of any
 <<variable-assignment,variable>> known at{nbsp}__**L**__.
 +
-The value of the special name `ICITTE` in this expression is the
-<<cur-offset,current offset>> (before encoding the integer).
+The value of the special name `ICITTE` (`int` type) in this expression
+is the <<cur-offset,current offset>> (before encoding the number).
 
 . The `:` character.
 
-. An encoding length in bits amongst `8`, `16`, `24`, `32`, `40`,
-  `48`, `56`, and `64`.
+. An encoding length in bits amongst:
++
+--
+The expression evaluates to an `int` value::
+    `8`, `16`, `24`, `32`, `40`, `48`, `56`, and `64`.
+
+The expression evaluates to a `float` value::
+    `32` and `64`.
+--
 
 . The `}` suffix.
 
@@ -635,6 +655,21 @@ Output:
 ----
 ====
 
+====
+Input:
+
+----
+{le}
+{2 * 0.0529 : 32}
+----
+
+Output:
+
+----
+ac ad d8 3d
+----
+====
+
 === LEB128 integer
 
 An _LEB128 integer_ represents a variable number of bytes encoding an
@@ -658,8 +693,8 @@ expression may contain:
   defined after{nbsp}__**L**__.
 --
 +
-The value of the special name `ICITTE` in this expression is the
-<<cur-offset,current offset>> (before encoding the integer).
+The value of the special name `ICITTE` (`int` type) in this expression
+is the <<cur-offset,current offset>> (before encoding the integer).
 
 . The `:` character.
 
@@ -763,7 +798,7 @@ A label is:
 . The `<` prefix.
 
 . A valid {py3} name which is not `ICITTE` (see
-  <<fixed-length-integer>>, <<leb128-integer>>, and
+  <<fixed-length-number>>, <<leb128-integer>>, and
   <<variable-assignment>> to learn more).
 
 . The `>` suffix.
@@ -778,7 +813,7 @@ A variable assignment is:
 . The ``pass:[{]`` prefix.
 
 . A valid {py3} name which is not `ICITTE` (see
-  <<fixed-length-integer>>, <<leb128-integer>>, and
+  <<fixed-length-number>>, <<leb128-integer>>, and
   <<variable-assignment>> to learn more).
 
 . The `=` character.
@@ -791,8 +826,8 @@ within a nested group), including the name of a label defined
 after{nbsp}__**L**__, as well as the name of any
 <<variable-assignment,variable>> known at{nbsp}__**L**__.
 +
-The value of the special name `ICITTE` in this expression is the
-<<cur-offset,current offset>>.
+The value of the special name `ICITTE` (`int` type) in this expression
+is the <<cur-offset,current offset>>.
 
 . The `}` suffix.
 
This page took 0.028535 seconds and 4 git commands to generate.