C Library Functions  - base2 (3)

NAME

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

CONTENTS

Synopsis
Description
Options
Returns
Example
Author
License

SYNOPSIS

function base2(int)

    integer,intent(in)           :: int
    character(len=:),allocatable :: base2

DESCRIPTION

Convert a whole number to a string in base 2.

This is often done with the B edit descriptor and an internal WRITE() statement, but is done without calling the I/O routines, and as a function.

OPTIONS

int input string representing numeric whole value

RETURNS

base2 string representing input value in base 2

EXAMPLE

Sample program:

     program demo_base2
     use M_strings, only : base2
     implicit none
        write(*,’(a)’) base2(huge(0))
        write(*,’(a)’) base2(0)
        write(*,’(a)’) base2(64)
        write(*,’(a)’) base2(-64)
        write(*,’(a)’) base2(-huge(0)-1)
     end program demo_base2
Results:

    > 1111111111111111111111111111111
    > 0
    > 1000000
    > 11111111111111111111111111000000
    > 10000000000000000000000000000000

AUTHOR

John S. Urban

LICENSE

Public Domain


Nemo Release 3.1 base2 (3) July 22, 2023
Generated by manServer 1.08 from a1003180-5aa9-472f-b2d5-08d2178b1607 using man macros.