Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhanced variable value validation. #1416

Closed
wants to merge 2 commits into from

Conversation

TakanoTaiga
Copy link
Member

Description

Abstract

This pull request enhances the validation of floating point values in mathematical calculations. Add a safeSqrt function to prevent incorrect square root calculations.

Background

Fixed what was pointed out in #1394.

Details

In floating-point arithmetic, calculating the square root of negative numbers can result in undefined behavior. The safeSqrt function ensures that only non-negative inputs are processed, returning zero when the input is negative.

References

Destructive Changes

N/A

Known Limitations

N/A

@TakanoTaiga TakanoTaiga added the bump patch If this pull request merged, bump patch version of the scenario_simulator_v2 label Oct 9, 2024
@TakanoTaiga TakanoTaiga self-assigned this Oct 9, 2024
Copy link

github-actions bot commented Oct 9, 2024

Checklist for reviewers ☑️

All references to "You" in the following text refer to the code reviewer.

  • Is this pull request written in a way that is easy to read from a third-party perspective?
  • Is there sufficient information (background, purpose, specification, algorithm description, list of disruptive changes, and migration guide) in the description of this pull request?
  • If this pull request contains a destructive change, does this pull request contain the migration guide?
  • Labels of this pull request are valid?
  • All unit tests/integration tests are included in this pull request? If you think adding test cases is unnecessary, please describe why and cross out this line.
  • The documentation for this pull request is enough? If you think adding documents for this pull request is unnecessary, please describe why and cross out this line.

Copy link

sonarcloud bot commented Oct 9, 2024

@TakanoTaiga TakanoTaiga marked this pull request as ready for review October 9, 2024 11:44
#include <limits>

namespace math
{
namespace arithmetic
{

template <typename T>
auto safeSqrt(T a)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add doxygen comment for describe safeSqrt behavior.

@hakuturu583 hakuturu583 deleted the fix/negative-sqrt-in-planConstraints branch October 10, 2024 05:06
@github-actions github-actions bot restored the fix/negative-sqrt-in-planConstraints branch October 10, 2024 05:07
@TakanoTaiga TakanoTaiga deleted the fix/negative-sqrt-in-planConstraints branch October 10, 2024 05:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bump patch If this pull request merged, bump patch version of the scenario_simulator_v2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants