Skip to content

Commit fb7ad79

Browse files
committed
Document 64-bit integer support more, formatting fixes, expand index
1 parent 8212a2d commit fb7ad79

File tree

6 files changed

+37
-30
lines changed

6 files changed

+37
-30
lines changed

docs/manual/building.qmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ doxygen docs/Doxyfile
1111

1212
## Requirements {-}
1313

14-
*TinyExpr++* must be compiled as C++17.\index{compiling!requirements}
14+
*TinyExpr++* must be compiled as C++17.\index{compiling!requirements} (Some additional features require C++20.)
1515

1616
MSVC, GCC, and Clang compilers are supported.

docs/manual/embedded-programming.qmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ Note that it is required to make the initial declaration of your
9292
## Floating-point Numbers {-#fp-numbers}
9393

9494
`double` is the default data type used for the parser's variable types, parameters, and return types.
95-
For embedded environments that require `float`\index{floating-point numbers!\texttt{float} vs. \texttt{double}},
95+
For embedded environments that require `float`\index{data types!\texttt{float} vs. \texttt{double}},
9696
compile with `TE_FLOAT` defined to use `float` instead.
9797

9898
When using this option, it is recommended to use the helper typedef `te_type`.

docs/manual/functions.qmd

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ The following built-in functions are available:
1717
| COSH(Number) | Hyperbolic cosine of *Number*. |
1818
| COT(Number) | Cotangent of *Number*. |
1919
| EXP(Number) | Euler to the power of *Number*. |
20-
| EVEN(Number) | Returns *Number* rounded up to the nearest even integer.<br>\linebreak *Number* is always rounded away from zero (e.g., `EVEN(-3)` = -4). |
20+
| EVEN(Number) | Returns *Number* rounded up to the nearest even integer.<br>\linebreak Values are always rounded away from zero (e.g., `EVEN(-3)` = -4). |
2121
| FAC(Number) | Returns the factorial of *Number*. The factorial of *Number* is equal to 1\*2\*3\*...\* *Number* |
2222
| FACT(Number) | Alias for `FAC()` |
2323
| FLOOR(Number) | Returns the largest integer not greater than *Number*.<br>\linebreak `FLOOR(-3.2)` = -4<br>\linebreak `FLOOR(3.2)` = 3 |
@@ -32,7 +32,7 @@ The following built-in functions are available:
3232
| NAN | Returns an invalid value (i.e., Not-a-number). |
3333
| NCR(Number, NumberChosen) | Alias for `COMBIN()`. |
3434
| NPR(Number, NumberChosen) | Alias for `PERMUT()`. |
35-
| ODD(Number) | Returns *Number* rounded up to the nearest odd integer.<br>\linebreak *Number* is always rounded away from zero (e.g., `ODD(-4)` = -5). |
35+
| ODD(Number) | Returns *Number* rounded up to the nearest odd integer.<br>\linebreak Values are always rounded away from zero (e.g., `ODD(-4)` = -5). |
3636
| PERMUT(Number, NumberChosen) | Returns the number of permutations for a given number (*NumberChosen*) of items that can be selected *Number* of items. A permutation is any set of items where order is important. (This differs from combinations, where order is not important). |
3737
| POW(Base, Exponent) | Raises *Base* to any power. For fractional exponents, *Base* must be greater than 0. |
3838
| POWER(Base, Exponent) | Alias for `POW()`. |
@@ -49,39 +49,41 @@ The following built-in functions are available:
4949
Table: Math Functions\index{functions!math}
5050
:::
5151

52-
::: {.minipage data-latex="{\textwidth}"}
52+
{{< pagebreak >}}
53+
5354
| Function | Description |
5455
| :-- | :-- |
5556
| BITAND(Number1, Number2) | Returns a bitwise 'AND' of two (integral) numbers. (Both numbers must be positive and cannot exceed `(2^48)-1`.) |
56-
| BITLROTATE8(Number, RotateAmount) | Returns *Number* left rotated left to the most significant bit by the specified number (*RotateAmount*) of bits.<br>\linebreak *Number* is rotated as an unsigned 8-bit integer.<br>\linebreak (Only available if compiled as C++20.) |
57-
| BITLROTATE16(Number, RotateAmount) | Returns *Number* left rotated left to the most significant bit by the specified number (*RotateAmount*) of bits.<br>\linebreak *Number* is rotated as an unsigned 16-bit integer.<br>\linebreak (Only available if compiled as C++20.) |
58-
| BITLROTATE32(Number, RotateAmount) | Returns *Number* left rotated left to the most significant bit by the specified number (*RotateAmount*) of bits.<br>\linebreak *Number* is rotated as an unsigned 32-bit integer.<br>\linebreak (Only available if compiled as C++20.) |
59-
| BITLROTATE64(Number, RotateAmount) | Returns *Number* left rotated left to the most significant bit by the specified number (*RotateAmount*) of bits.<br>\linebreak *Number* is rotated as an unsigned 64-bit integer.<br>\linebreak (Only available if compiled as C++20.) |
60-
| BITLROTATE(Number, RotateAmount) | Returns *Number* left rotated left to the most significant bit by the specified number (*RotateAmount*) of bits.<br>\linebreak *Number* is rotated as either a 32- or 64-bit integer (depending on what is supported by the compiler).<br>\linebreak (Only available if compiled as C++20.) |
61-
| BITLSHIFT(Number, ShiftAmount) | Returns *Number* left shifted by the specified number (*ShiftAmount*) of bits.<br>\linebreak *Number* cannot exceed `(2^48)-1` and *ShiftAmount* cannot exceed `53` (or `63`, if 64-bit is supported). |
57+
| BITLROTATE8(Number, RotateAmount) | Returns *Number* left rotated left to the most significant bit by the specified number (*RotateAmount*) of bits.<br>\linebreak Numbers are rotated as an unsigned 8-bit integer.<br>\linebreak (Only available if compiled as C++20.) |
58+
| BITLROTATE16(Number, RotateAmount) | Returns *Number* left rotated left to the most significant bit by the specified number (*RotateAmount*) of bits.<br>\linebreak Numbers are rotated as an unsigned 16-bit integer.<br>\linebreak (Only available if compiled as C++20.) |
59+
| BITLROTATE32(Number, RotateAmount) | Returns *Number* left rotated left to the most significant bit by the specified number (*RotateAmount*) of bits.<br>\linebreak Numbers are rotated as an unsigned 32-bit integer.<br>\linebreak (Only available if compiled as C++20.) |
60+
| BITLROTATE64(Number, RotateAmount) | Returns *Number* left rotated left to the most significant bit by the specified number (*RotateAmount*) of bits.<br>\linebreak Numbers are rotated as an unsigned 64-bit integer.<br>\linebreak (Only available if compiled as C++20.) |
61+
| BITLROTATE(Number, RotateAmount) | Returns *Number* left rotated left to the most significant bit by the specified number (*RotateAmount*) of bits.<br>\linebreak Numbers are rotated as either a 32- or 64-bit integer (depending on what is supported by the compiler).<br>\linebreak (Only available if compiled as C++20.) |
62+
| BITLSHIFT(Number, ShiftAmount) | Returns *Number* left shifted by the specified number (*ShiftAmount*) of bits.<br>\linebreak Numbers cannot exceed `(2^48)-1` and *ShiftAmount* cannot exceed `53` (or `63`, if 64-bit is supported). |
6263
| BITNOT8(Number) | Returns a bitwise 'NOT' of a 8-bit integer. |
6364
| BITNOT16(Number) | Returns a bitwise 'NOT' of a 16-bit integer. |
6465
| BITNOT32(Number) | Returns a bitwise 'NOT' of a 32-bit integer. |
6566
| BITNOT64(Number) | Returns a bitwise 'NOT' of a 64-bit integer (if 64-bit integers are supported). |
6667
| BITNOT(Number) | Returns a bitwise 'NOT' of a 32- or 64-bit integer (depending on whether 64-bit is supported). |
6768
| BITOR(Number1, Number2) | Returns a bitwise 'OR' of two (integral) numbers. (Both numbers must be positive and cannot exceed `(2^48)-1`.) |
68-
| BITRROTATE8(Number, RotateAmount) | Returns *Number* right rotated right to the least significant bit by the specified number (*RotateAmount*) of bits.<br>\linebreak *Number* is rotated as an unsigned 8-bit integer.<br>\linebreak (Only available if compiled as C++20.) |
69-
| BITRROTATE16(Number, RotateAmount) | Returns *Number* right rotated right to the least significant bit by the specified number (*RotateAmount*) of bits.<br>\linebreak *Number* is rotated as an unsigned 16-bit integer.<br>\linebreak (Only available if compiled as C++20.) |
70-
| BITRROTATE32(Number, RotateAmount) | Returns *Number* right rotated right to the least significant bit by the specified number (*RotateAmount*) of bits.<br>\linebreak *Number* is rotated as an unsigned 32-bit integer.<br>\linebreak (Only available if compiled as C++20.) |
71-
| BITRROTATE64(Number, RotateAmount) | Returns *Number* right rotated right to the least significant bit by the specified number (*RotateAmount*) of bits.<br>\linebreak *Number* is rotated as an unsigned 64-bit integer.<br>\linebreak (Only available if compiled as C++20.) |
72-
| BITRROTATE(Number, RotateAmount) | Returns *Number* right rotated right to the least significant bit by the specified number (*RotateAmount*) of bits.<br>\linebreak *Number* is rotated as either a 32- or 64-bit integer (depending on what is supported by the compiler).<br>\linebreak (Only available if compiled as C++20.) |
73-
| BITRSHIFT(Number, ShiftAmount) | Returns *Number* right shifted by the specified number (*ShiftAmount*) of bits.<br>\linebreak *Number* cannot exceed `(2^48)-1` and *ShiftAmount* cannot exceed `53` (or `63`, if 64-bit is supported). |
69+
| BITRROTATE8(Number, RotateAmount) | Returns *Number* right rotated right to the least significant bit by the specified number (*RotateAmount*) of bits.<br>\linebreak Numbers are rotated as an unsigned 8-bit integer.<br>\linebreak (Only available if compiled as C++20.) |
70+
| BITRROTATE16(Number, RotateAmount) | Returns *Number* right rotated right to the least significant bit by the specified number (*RotateAmount*) of bits.<br>\linebreak Numbers are rotated as an unsigned 16-bit integer.<br>\linebreak (Only available if compiled as C++20.) |
71+
| BITRROTATE32(Number, RotateAmount) | Returns *Number* right rotated right to the least significant bit by the specified number (*RotateAmount*) of bits.<br>\linebreak Numbers are rotated as an unsigned 32-bit integer.<br>\linebreak (Only available if compiled as C++20.) |
72+
| BITRROTATE64(Number, RotateAmount) | Returns *Number* right rotated right to the least significant bit by the specified number (*RotateAmount*) of bits.<br>\linebreak Numbers are rotated as an unsigned 64-bit integer.<br>\linebreak (Only available if compiled as C++20.) |
73+
| BITRROTATE(Number, RotateAmount) | Returns *Number* right rotated right to the least significant bit by the specified number (*RotateAmount*) of bits.<br>\linebreak Numbers are rotated as either a 32- or 64-bit integer (depending on what is supported by the compiler).<br>\linebreak (Only available if compiled as C++20.) |
74+
| BITRSHIFT(Number, ShiftAmount) | Returns *Number* right shifted by the specified number (*ShiftAmount*) of bits.<br>\linebreak Numbers cannot exceed `(2^48)-1` and *ShiftAmount* cannot exceed `53` (or `63`, if 64-bit is supported). |
7475
| BITXOR(Number1, Number2) | Returns a bitwise 'XOR' of two (integral) numbers. (Both numbers must be positive and cannot exceed `(2^48)-1`.) |
7576
| SUPPORTS32BIT() | Returns true if 32-bit integers are supported. This will affect the supported range of values for bitwise operations. |
7677
| SUPPORTS64BIT() | Returns true if 64-bit integers are supported. This will affect the supported range of values for bitwise operations. |
7778

7879
Table: Engineering Functions\index{functions!engineering}
79-
:::
8080

81-
::: {.notesection data-latex=""}
81+
::: {.warningsection data-latex=""}
8282
Defining `TE_FLOAT` will disable all bitwise functions and operators.
8383
:::
8484

85+
{{< pagebreak >}}
86+
8587
::: {.minipage data-latex="{\textwidth}"}
8688
| Function | Description |
8789
| :-- | :-- |
@@ -110,5 +112,5 @@ Any subsequent arguments that evaluate to NaN will be ignored.
110112

111113
## Compatibility Note {-}
112114

113-
`BITNOT` will call either `BITNOT32` or `BITNOT64`, depending on whether 64-bit integers are supported.
115+
`BITNOT` will call either `BITNOT32` or `BITNOT64`, depending on whether 64-bit integers\index{data types!\texttt{64-bit integer}} are supported.
114116
This differs from *Excel*, which only works with 16-bit integers. To match the behavior of *Excel*, explicitly call `BITNOT16`.

docs/manual/index.qmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ It's open-source, free, easy-to-use, and self-contained in a single source and h
4343
- Case insensitive.
4444
- Supports non-US formulas (e.g., `POW(2,2; 2)` instead of `POW(2.2, 2)`).
4545
- Supports C and C++ style comments within math expressions.
46-
- Can be configured to use `double` or [`float`](#te-float) for its calculations.
46+
- Can be configured to use `double`, `long double`, or [`float`](#te-float) for its calculations.
4747
- Released under the zlib license - free for nearly any use.
4848
- Easy to use and integrate with your code.
4949
- Thread-safe; parser is in a self-contained object.

docs/manual/operators.qmd

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ The following operators\index{operators} are supported within math expressions:
2323
| & | Either logical (the default) or bitwise conjunction (AND). |
2424
| && | Logical conjunction (AND). |
2525
| \| | Either Logical (the default) or bitwise alternative (OR). |
26-
| \|\ | | Logical alternative (OR). |
26+
| \|\| | Logical alternative (OR). |
2727
| ( ) | Groups sub-expressions, overriding the order of operations. |
2828
| ~ | Bitwise NOT. |
29-
| << | Bitwise left shift. |
30-
| >> | Bitwise right shift. |
31-
| <<< | Bitwise left rotate. (Only available if compiled as C++20.) |
32-
| >>> | Bitwise right rotate. (Only available if compiled as C++20.) |
29+
| `<<` | Bitwise left shift. |
30+
| `>>` | Bitwise right shift. |
31+
| `<<<` | Bitwise left rotate. (Only available if compiled as C++20.) |
32+
| `>>>` | Bitwise right rotate. (Only available if compiled as C++20.) |
3333

3434
Table: Operators
3535
:::
@@ -48,8 +48,8 @@ For operators, the order of precedence is:
4848
| ^ | Exponentiation. |
4949
| \*, /, and % | Multiplication, division, and modulus. |
5050
| \+ and - | Addition and subtraction. |
51-
| <<, >>, <<<, >>> | Bitwise left and right shift and rotation. |
52-
| <, \>, \>=, <= | Relational comparisons. |
51+
| `<<`, `>>`, `<<<`, `>>>` | Bitwise left and right shift and rotation. |
52+
| \<, \>, \>=, <= | Relational comparisons. |
5353
| \= and \!\= | Equality comparisons. |
5454
| && | Logical conjunction (AND). |
5555
| \|\| | Logical alternative (OR). |
@@ -58,7 +58,7 @@ For operators, the order of precedence is:
5858
| \| | Bitwise OR (if `TE_BITWISE_OPERATORS` is defined). |
5959
:::
6060

61-
::: {.notesection data-latex=""}
61+
::: {.warningsection data-latex=""}
6262
Defining `TE_FLOAT` will disable all bitwise functions and operators.
6363
:::
6464

docs/manual/usage.qmd

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,12 @@ The following data types and constants are used throughout *TinyExpr++*:
77
`te_parser`: The main class for defining an evaluation engine and solving expressions.
88

99
`te_type`: The data type for variables, function parameters, and results.
10-
By default this is `double`, but can be `float` when [`TE_FLOAT`](#te-float) is defined.
10+
By default this is `double`, but can be `float` (when [`TE_FLOAT`](#te-float) is defined)
11+
or `long double` (when `TE_LONG_DOUBLE` is defined).
12+
13+
If `long double`\index{data types!\texttt{long double}} is in use, then various bitwise functions (`BITNOT()`, `BITRROTATE()`)
14+
may be able to support 64-bit integers\index{data types!\texttt{64-bit integer}}. This will depend on the compiler used to build the library and can be verified by calling
15+
`te_parser::supports_64bit()` in your code or `SUPPORTS64BIT()` in an expression at runtime.
1116

1217
`te_variable`: A user-defined variable or function that can be embedded into a `te_parser`.
1318
(Refer to [custom variables](#custom-variables).)

0 commit comments

Comments
 (0)