Skip to content

Conversation

MduPlessis-1
Copy link
Contributor

Take the absolute value of the value in numValDigits to fix the precision loss check for negative values. Fixes #4886.

@obiltschnig obiltschnig requested a review from aleks-f February 28, 2025 10:42
@obiltschnig obiltschnig added this to 1.14 Feb 28, 2025
@obiltschnig obiltschnig added this to the Release 1.14.2 milestone Feb 28, 2025
Copy link
Member

@obiltschnig obiltschnig left a comment

Choose a reason for hiding this comment

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

instead of llabs(), use std::abs()

@aleks-f aleks-f removed this from 1.14 Feb 28, 2025
@aleks-f aleks-f added this to 1.14 Feb 28, 2025
Copy link
Member

@aleks-f aleks-f left a comment

Choose a reason for hiding this comment

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

@MduPlessis-1 please add a test for this

@MduPlessis-1
Copy link
Contributor Author

MduPlessis-1 commented Feb 28, 2025

instead of llabs(), use std::abs()

Using std::abs() here causes a compilation error for ambiguous overloads of abs() since this template can be called on unsigned types. So the options are:

  1. Keep it as-is
  2. U locVal = -static_cast<U>(value); (refer to stackoverflow for details)
  3. Some way to have special code for signed/unsigned types.

@matejk
Copy link
Contributor

matejk commented Feb 28, 2025

instead of llabs(), use std::abs()

Using std::abs() here causes a compilation error for ambiguous overloads of abs() since this template can be called on unsigned types. So the options are:

  1. Keep it as-is
  2. U locVal = -static_cast<U>(value); (refer to stackoverflow for details)
  3. Some way to have special code for signed/unsigned types.

One solution would also be to use:

U locVal = (value < 0) ? -value : value;

@obiltschnig
Copy link
Member

Something involving std::is_signed_t<> and std::make_signed_t<> (to resolve the ambiguity) maybe?

@matejk matejk removed this from the Release 1.14.2 milestone Mar 11, 2025
@matejk matejk removed this from 1.14 Mar 11, 2025
@matejk
Copy link
Contributor

matejk commented Mar 11, 2025

Replaced with PR #4894

@matejk matejk closed this Mar 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Poco::Dynamic::Var conversion to floating point does not handle precision checks correctly for negative numbers.
4 participants