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

Unify and improve handling of float point values in 'builtInGetValue()' #1910

Open
2 tasks done
grospelliergilles opened this issue Jan 12, 2025 · 0 comments
Open
2 tasks done
Assignees
Labels
arcane Arcane Component enhancement New feature or request refactoring Code refactoring and cleanup

Comments

@grospelliergilles
Copy link
Member

grospelliergilles commented Jan 12, 2025

With version 3.14 of Arcane and before, the handling of conversion from String to Real types (Real, Real2, Real3, Real2x2 and Real3x3) is done like this:

  • for Real, we use std::strtod().
  • for Real2, Real3, Real2x2 and Real3x3 we use std::istream::operator>>.

This leads to several inconsistencies because std::istream and std::strtod() does not have the same rules for conversions. std::strtod() allows values like nan or infinity and raw floating point values (like 0x43p-2) but this is not the case for std::istream. So in Arcane we are allowed to use nan in a file when we read a Real but not if we read a Real2 for example.

std::strtod() also have issues because it is locale dependant. If the default locale is not C, then the behavior for reading floating point values may change because the decimal separator may change (for example in french it is ',' instead of '.').

So, to have a consistant behavior, we have to do the following:

@grospelliergilles grospelliergilles added enhancement New feature or request arcane Arcane Component refactoring Code refactoring and cleanup labels Jan 12, 2025
@grospelliergilles grospelliergilles self-assigned this Jan 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arcane Arcane Component enhancement New feature or request refactoring Code refactoring and cleanup
Projects
None yet
Development

No branches or pull requests

1 participant