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:
With version 3.14 of Arcane and before, the handling of conversion from
StringtoRealtypes (Real,Real2,Real3,Real2x2andReal3x3) is done like this:Real, we usestd::strtod().Real2,Real3,Real2x2andReal3x3we usestd::istream::operator>>.This leads to several inconsistencies because
std::istreamandstd::strtod()does not have the same rules for conversions.std::strtod()allows values likenanorinfinityand raw floating point values (like0x43p-2) but this is not the case forstd::istream. So in Arcane we are allowed to usenanin a file when we read aRealbut not if we read aReal2for example.std::strtod()also have issues because it is locale dependant. If the default locale is notC, 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:
Real,Real2,Real3,Real2x2,Real3x3,floatandlong double:Real2: Add support to convert string to 'Real2' using same mechanism as string to real #1918Real3: Add support to convert String to Real3 using the same mechanism as String to Real #1949std::from_chars()instead ofstd::strtod()because it is locale independant : Usestd::from_chars()instead ofstd::strtod()to convert strings to double if C++20 is enabled #1911