Skip to content

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

@grospelliergilles

Description

@grospelliergilles

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:

Metadata

Metadata

Labels

arcaneArcane ComponentenhancementNew feature or requestrefactoringCode refactoring and cleanup

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions