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

std::abs used instead of std::fabs #481

Closed
sgromoll opened this issue Oct 30, 2021 · 2 comments
Closed

std::abs used instead of std::fabs #481

sgromoll opened this issue Oct 30, 2021 · 2 comments
Labels
bug Something isn't working invalid This doesn't seem right

Comments

@sgromoll
Copy link

sgromoll commented Oct 30, 2021

Describe the bug
In asi_base.cpp, std::abs is used in ASIBase::SetTemperature to compare the current temperature difference to a floating point value like TEMP_THRESHOLD (0.25). std::abs takes (and returns) and int/long, so presumably std::fabs should be used here since you are comparing to a float.

This occurs in several places in the file (and from a quick grep many places in this repo).

To Reproduce
N/A

Expected behavior
N/A

Screenshots
N/A

Desktop (please complete the following information):

  • OS:
  • Version [e.g. 1.7.6, GIT..etc]

Log Files
Make sure to enable logging and include log files https://indilib.org/support/logs-submission.html

@sgromoll sgromoll added the bug Something isn't working label Oct 30, 2021
@knro knro added the invalid This doesn't seem right label Oct 30, 2021
@knro
Copy link
Collaborator

knro commented Oct 30, 2021

it actually returns double. Check the definition in std_abs.h

#ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
  inline _GLIBCXX_CONSTEXPR double
  abs(double __x)
  { return __builtin_fabs(__x); }

  inline _GLIBCXX_CONSTEXPR float
  abs(float __x)
  { return __builtin_fabsf(__x); }

  inline _GLIBCXX_CONSTEXPR long double
  abs(long double __x)
  { return __builtin_fabsl(__x); }
#endif

@sgromoll
Copy link
Author

sgromoll commented Nov 5, 2021

Yep, thanks for clarification.

@sgromoll sgromoll closed this as completed Nov 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

2 participants