Skip to content

Commit

Permalink
need high resolution in codebase
Browse files Browse the repository at this point in the history
  • Loading branch information
urbanjost committed Sep 21, 2024
1 parent 76e9117 commit 11834bc
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/M_strings.F90
Original file line number Diff line number Diff line change
Expand Up @@ -10518,7 +10518,7 @@ logical function codebase(inval10,outbase,answer)
integer,intent(in) :: outbase
character(len=*),intent(out) :: answer
integer :: n
real :: inval10_local
real(kind=real64) :: inval10_local
integer :: outbase_local
integer :: in_sign
answer=''
Expand Down
17 changes: 17 additions & 0 deletions test/test_suite_M_strings.f90
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,9 @@ end subroutine test_base2
subroutine test_codebase()
character(len=:),allocatable :: in(:)
integer,allocatable :: expected(:)
character(len=80) :: answer, baseformat, expect
integer :: i, j, base, ierr
logical :: ier
call unit_test_start('codebase','[BASE] convert whole number in base 10 to string in base [2-36]')

! convert base10 values to base2 strings
Expand All @@ -523,6 +526,20 @@ subroutine test_codebase()
call checkit(['123123'],[1755],4)
call checkit(['10'],[16],16)
call checkit(['10'],[8],8)
! test against Fortran BOZ values
do j=1,3
select case(j)
case(1); base=2; baseformat='(b0)'
case(2); base=8; baseformat='(o0)'
case(3); base=16; baseformat='(z0)'
end select
do i=0,huge(0),1237
ier=codebase(i,base,answer)
write(expect,baseformat)i
if(answer.ne.expect.or..not.ier) &
& call unit_test('codebase',F,'expected',expect,'got',answer)
enddo
enddo

call unit_test_end('codebase')
contains
Expand Down

0 comments on commit 11834bc

Please sign in to comment.