Manual Reference Pages  - codebase (3m_strings)

NAME

codebase(3f) - [M_strings:BASE] convert whole number in base 10 to string in base [2-36] (LICENSE:PD)

CONTENTS

Synopsis
Description
Options
Returns
Examples
Author
License

SYNOPSIS

logical function codebase(in_base10,out_base,answer)

   integer,intent(in)           :: in_base10
   integer,intent(in)           :: out_base
   character(len=*),intent(out) :: answer

DESCRIPTION

Convert a number from base 10 to base OUT_BASE. The function returns [char46]FALSE. if OUT_BASE is not in the range [2..36] or if number IN_BASE10 is too big.

The letters A,B,...,Z represent 10,11,...,36 in the base > 10.

OPTIONS

in_base10
  whole number to convert to an alternate base
out_base
  the desired base of the output
answer the input value converted to a string representing the original number IN_BASE10 in base OUT_BASE.

RETURNS

Returns .true. if no error occurred, else returns .false. .

EXAMPLES

Sample program:

   program demo_codebase
   use M_strings, only : codebase
   implicit none
   character(len=20) :: answer
   integer           :: i, j
   logical           :: ierr
   do j=1,100
      do i=2,36
         ierr=codebase(j,i,answer)
         write(*,*)’VALUE=’,j,’ BASE=’,i,’ ANSWER=’,answer
      enddo
   enddo
   end program demo_codebase

AUTHOR

John S. Urban

    Ref.: "Math matiques en Turbo-Pascal by
           M. Ducamp and A. Reverchon (2),
           Eyrolles, Paris, 1988".

based on a F90 Version By J-P Moreau (www.jpmoreau.fr)

LICENSE

Public Domain


Nemo Release 3.1 codebase (3m_strings) July 20, 2024
Generated by manServer 1.08 from f58dc299-2eb1-4884-9c96-e9bab44d3d4b using man macros.