Debian Codegraph @

doc/src/intrinsics/bit/shiftl.md

raw
1 # shiftl(x, shift): Shift Left
2
3 Logical shift left function.
4
5 ## Declaration
6
7 ### Syntax
8
9 ```fortran
10 retval = shiftl(int(number), 31);
11 integer(int32) function shiftli32(i, shift)
12 ```
13
14 ### Arguments
15
16 `x` is an integer input value.
17
18 `shift` an unsigned integer value less than or equal to the bit size of `x`. The
19 possible values are 7, 31, and 63.
20
21 ### Return values
22
23 The return value is of type integer and of the same kind as `x`.
24
25 ## Description
26
27 **shiftl(x, shift)** logically left shifts `x` by `shift` number of bits. `shiftl`
28 shifts from LSB(**L**east **S**ignificant **B**it) to MSB(**M**ost **S**ignificant **B**it). Bits
29 shifted from the left end i.e., MSB bits are lost. Zeroes are appended to the
30 opposite right end.
31
32 ## Types
33
34 Supported types in unsigned integer value `x` and unsigned integer value `shift`
35 from (7, 31, 63) less than or equal to bit size of `x`.
36
37 ```
38 interface shiftl
39 module procedure shiftli8, shiftli32, shiftli64
40 end interface
41
42 contains
43
44 interface
45 integer(int8) function shiftli8(i, shift) result(r)
46 integer(int8), intent(in) :: i
47 integer :: shift
48 end function
49
50 integer(int32) function shiftli32(i, shift) result(r)
51 integer(int32) :: i
52 integer :: shift
53 end function
54
55 integer(int64) function shiftli64(i, shift) result(r)
56 integer(int64) :: i
57 integer :: shift
58 end function
59 end interface
60 ```
61
62 ## Examples
63
64 ```fortran
65 program intrinsics_shiftl
66 implicit none
67 integer, parameter :: x = kind(2)
68 integer :: retval
69 retval = shiftl(int(x), 7)
70 print *, retval
71 end program
72 ```
73
74 **Result:**
75
76 ```
77 4
78 ```
79
80 ## See Also
81
82 [shiftr](shiftr.md).