Skip to content

Commit

Permalink
Add notes for remap's return when istart and istop are the same
Browse files Browse the repository at this point in the history
Co-Authored-By: Rémi Verschelde <rverschelde@gmail.com>
Co-Authored-By: kleonc <9283098+kleonc@users.noreply.github.com>
  • Loading branch information
3 people committed May 7, 2024
1 parent 7ebc866 commit 26feefa
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions doc/classes/@GlobalScope.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1097,6 +1097,7 @@
remap(75, 0, 100, -1, 1) # Returns 0.5
[/codeblock]
For complex use cases where multiple ranges are needed, consider using [Curve] or [Gradient] instead.
[b]Note:[/b] If [code]istart == istop[/code], the return value is undefined (most likely NaN, INF, or -INF).
</description>
</method>
<method name="rid_allocate_id">
Expand Down
3 changes: 3 additions & 0 deletions tests/core/math/test_math_funcs.h
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,9 @@ TEST_CASE_TEMPLATE("[Math] remap", T, float, double) {
CHECK(Math::remap((T)-100.0, (T)-100.0, (T)-200.0, (T)0.0, (T)-1000.0) == doctest::Approx((T)0.0));
CHECK(Math::remap((T)-200.0, (T)-100.0, (T)-200.0, (T)0.0, (T)-1000.0) == doctest::Approx((T)-1000.0));
CHECK(Math::remap((T)-250.0, (T)-100.0, (T)-200.0, (T)0.0, (T)-1000.0) == doctest::Approx((T)-1500.0));

// Note: undefined behaviour can happen when `p_istart == p_istop`. We don't bother testing this as it will
// vary between hardware and compilers properly implementing IEEE 754.
}

TEST_CASE_TEMPLATE("[Math] angle_difference", T, float, double) {
Expand Down

0 comments on commit 26feefa

Please sign in to comment.