Skip to content

Commit

Permalink
Added TE_FLOAT preprocessor flag to use float instead of double for t…
Browse files Browse the repository at this point in the history
…he parser's data type.
  • Loading branch information
Blake-Madden committed Nov 17, 2023
1 parent 2257354 commit c2fdaef
Show file tree
Hide file tree
Showing 5 changed files with 316 additions and 289 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ The following are changes from the original TinyExpr C library:
- Added `set_constant()` function to find and update the value of a constant (custom) variable by name.
(In this context, a constant is a variable mapped to a double value in the parser, rather than mapped to a runtime variable.)
- Added `get_constant()` function to return the value of a constant (custom) variable by name.
- Added `TE_FLOAT` preprocessor flag to use `float` instead of `double` for the parser's data type.
- Binary search (i.e., `std::set`) is now used to look up custom variables and functions (small optimization).
- You no longer need to specify the number of arguments for custom functions; it will deduce that for you.
- The position of an error when evaluating an expression is now managed by the `te_parser` class and accessible via `get_last_error_position()`.
Expand Down
10 changes: 10 additions & 0 deletions docs/manual/28-CompileTimeOptions.Rmd
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Compile-time Options

## `TE_FLOAT` {-}

`double` is the default data type used for the parser's variable types, parameters, and return types.
For embedded environments that require `float`, compile with `TE_FLOAT` defined to use `float` instead.

When using this option, it is recommended to use the helper typedef `te_type`.
This will map to either `float` or `double` (depending on whether `TE_FLOAT` is defined).
By defining your functions and variables with `te_type`,
you won't need to replace `double` and `float` if needing to change this compiler flag.

## `TE_POW_FROM_RIGHT` {-}

By default, *TinyExpr++* does exponentiation from left to right. For example:
Expand Down
Loading

0 comments on commit c2fdaef

Please sign in to comment.