Skip to content

Commit

Permalink
Try another algorithm
Browse files Browse the repository at this point in the history
  • Loading branch information
minhqdao committed Feb 26, 2024
1 parent ef39426 commit e2b6d84
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions src/version_f.f90
Original file line number Diff line number Diff line change
Expand Up @@ -481,14 +481,21 @@ elemental integer function string_t_2i(this)
!> Convert an integer to a string.
pure function int2s(num) result(str)
integer, intent(in) :: num
character(:), allocatable :: str
character(len=:), allocatable :: str

if (num == 0) then
str = '0'
else
allocate (character(int(log10(real(num))) + 1) :: str)
write (str, '(I0)') num
end if
integer :: num_digits, tmp

tmp = num
num_digits = 0

do
num_digits = num_digits + 1
tmp = tmp/10
if (tmp == 0) exit
end do

allocate (character(num_digits) :: str)
write (str, '(I0)') num
end

!> Check for valid prerelease or build data and build identfiers from
Expand Down

0 comments on commit e2b6d84

Please sign in to comment.