Closed amanotk closed 3 months ago
This solves an issue when IEEE floating-point rounding mode is manually set to IEEE_DOWN. The original code in the string_to_integer subroutine
IEEE_DOWN
string_to_integer
ndigits_digits = floor(log10(real(ndigits)))+1
erroneously returns 1 even when ndigits is 10 (while the correct value should be 2).
ndigits
The following code is the minimum reproducible example of the problem. The last deserialize will result in a crush.
deserialize
program jsontest use :: ieee_arithmetic use :: json_module type(json_file) :: file call ieee_set_rounding_mode(ieee_down) call file%initialize() call file%deserialize('{"foo" : 100}') print *, "ok 1" call file%deserialize('{"foo" : 100, "bar" : 1000}') print *, "ok 2" call file%deserialize('{"foo" : 100, "bar" : 1000, "baz" : 10000}') print *, "ok 3" call file%destroy() end program jsontest
I assume simply changing floor to nint should solve the issue without any side effects.
floor
nint
thanks! I'll take a look at this...
Merging #545 (e4bfffc) into master (7819919) will not change coverage. The diff coverage is 100.00%.
100.00%
This solves an issue when IEEE floating-point rounding mode is manually set to
IEEE_DOWN
. The original code in thestring_to_integer
subroutineerroneously returns 1 even when
ndigits
is 10 (while the correct value should be 2).The following code is the minimum reproducible example of the problem. The last
deserialize
will result in a crush.I assume simply changing
floor
tonint
should solve the issue without any side effects.