Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Integer-to-character conversion #676

HugoMVale started this conversation in General
Discussion options

Hello,
Is there a stdlib function which allows to convert an integer to a character vector (opposite of ichar if I understand well)?
I mean, something more or less like:

 function itoa(i) result(res)
 !------------------------------------------------------------------------------------------
 !! Convert integer to string.
 !------------------------------------------------------------------------------------------
 integer, intent(in) :: i
 !! Integer
 character(:), allocatable :: res
 character(range(i)+2) :: tmp
 write(tmp,'(i0)') i
 res = trim(tmp)
 end function

Thanks for any hint.

You must be logged in to vote

Replies: 1 comment 1 reply

Comment options

to_string ( https://stdlib.fortran-lang.org/page/specs/stdlib_strings.html#to_string) is most likely what you are looking for Le sam. 10 sept. 2022 à 19:18, HugoMVale ***@***.***> a écrit :
...
Hello, Is there a stdlib function which allows to convert an integer to a character vector (opposite of ichar if I understand well)? I mean, something more or less like: function itoa(i) result(res) !------------------------------------------------------------------------------------------ !! Convert integer to string. !------------------------------------------------------------------------------------------ integer, intent(in) :: i !! Integer character(:), allocatable :: res character(range(i)+2) :: tmp write(tmp,'(i0)') i res = trim(tmp) end function Thanks for any hint. — Reply to this email directly, view it on GitHub <#676>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AD5RO7DPT62PJHDVC4ZNETTV5S7H7ANCNFSM6AAAAAAQJNEVHE> . You are receiving this because you are subscribed to this thread.Message ID: ***@***.***>
You must be logged in to vote
1 reply
Comment options

Thanks a lot, @jvdp1. Now that you told me where to search for, I realized that the section Contributing and specs has all the necessary explanations, but I never thought of looking under than title... I searched directly under Modules and Procedures and got lost. Perhaps we could rename Contributing and specs to API reference (as numpy) or similar.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants

AltStyle によって変換されたページ (->オリジナル) /