[UP]


Manual Reference Pages  - anyscalar_to_int64 (3)

NAME

anyscalar_to_int64(3f) - [M_anything] convert integer any kind to integer(kind=int64) (LICENSE:PD)

CONTENTS

Synopsis
Description
Options
Results
Example
Author
License

SYNOPSIS

impure elemental function anyscalar_to_int64(intin) result(value)

    class(*),intent(in) :: intin
    integer(kind=int64) :: value

DESCRIPTION

This function uses polymorphism to allow arguments of different INTEGER types as input. It is typically used to create other procedures that can take many scalar arguments as input options, equivalent to passing the parameter VALUE as int(VALUE,0_int64).

OPTIONS

VALUEIN
  input argument of a procedure to convert to type INTEGER(KIND=int64). May be of KIND kind=int8, kind=int16, kind=int32, kind=int64.

RESULTS

The value of VALUIN converted to INTEGER(KIND=INT64).

EXAMPLE

Sample program

    program demo_anyscalar_to_int64
    use, intrinsic :: iso_fortran_env, only : int8, int16, int32, int64
    implicit none
       ! call same function with many scalar input types
       write(*,*)squarei(huge(0_int8)),huge(0_int8) , &
       & ’16129’
       write(*,*)squarei(huge(0_int16)),huge(0_int16) , &
       & ’1073676289’
       write(*,*)squarei(huge(0_int32)),huge(0_int32) , &
       & ’4611686014132420609’
       write(*,*)squarei(huge(0_int64)),huge(0_int64) , &
       & ’85070591730234615847396907784232501249’
    contains
    !
    function squarei(invalue)
    use M_anything, only : anyscalar_to_int64
    class(*),intent(in)  :: invalue
    doubleprecision      :: invalue_local
    doubleprecision      :: squarei
       invalue_local=anyscalar_to_int64(invalue)
       squarei=invalue_local*invalue_local
    end function squarei
    !
    end program demo_anyscalar_to_int64

Results

   16129.000000000000       127 \
   16129
   1073676289.0000000       32767 \
   1073676289
   4.6116860141324206E+018  2147483647 \
   4611686014132420609
   8.5070591730234616E+037  9223372036854775807 \
   85070591730234615847396907784232501249
   2.8948022309329049E+076 170141183460469231731687303715884105727 \
   28948022309329048855892746252171976962977213799489202546401021394546514198529

AUTHOR

John S. Urban

LICENSE

Public Domain


anyscalar_to_int64 (3) October 17, 2020
Generated by manServer 1.08 from 4a6ff49d-6502-465d-bf4b-c13632c34d22 using man macros.