Description
The general issue to solve with this is the conversion from intrinsic data types to character values, which is in Fortran only possible by internal IO:
write(string, '(g0)') val
This is error prone since the character variable has to be a fixed size character variable with sufficient length and this approach is not usable in a functional way. In #69 such functionality for stdlib has been briefly discussed. This issue should work out the details for such routines.
Converting integers and logicals to character values without internal IO is quite straight-forward (see #336), somewhat less straight-forward is reliably converting real and complex values to character sequences.
To get started such routines for the real and complex case could be implemented by internal IO until we found a robust way to handle all exceptional values (NaN
, Inf
, -Inf
) and correctly write the decimal places and exponent for a given real or complex value without resorting to internal IO or excessive use of logarithms and exponentials.