You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
use the same mechanism to read all floating point values : Real, Real2, Real3, Real2x2, Real3x3, float and long double:
With version 3.14 of Arcane and before, the handling of conversion from
String
toReal
types (Real
,Real2
,Real3
,Real2x2
andReal3x3
) is done like this:Real
, we usestd::strtod()
.Real2
,Real3
,Real2x2
andReal3x3
we usestd::istream::operator>>
.This leads to several inconsistencies because
std::istream
andstd::strtod()
does not have the same rules for conversions.std::strtod()
allows values likenan
orinfinity
and raw floating point values (like0x43p-2
) but this is not the case forstd::istream
. So in Arcane we are allowed to usenan
in a file when we read aReal
but not if we read aReal2
for 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
,float
andlong 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 #1911The text was updated successfully, but these errors were encountered: