Sync
This commit is contained in:
parent
6f050a029e
commit
776bba907c
3887 changed files with 59894 additions and 7280 deletions
25
Task/Bitwise-operations/Fortran/bitwise-operations-3.f
Normal file
25
Task/Bitwise-operations/Fortran/bitwise-operations-3.f
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
program bits_rosetta
|
||||
implicit none
|
||||
|
||||
call bitwise(14,3)
|
||||
|
||||
contains
|
||||
|
||||
subroutine bitwise(a,b)
|
||||
implicit none
|
||||
integer, intent(in):: a,b
|
||||
character(len=*), parameter :: fmt1 = '(2(a,i10))'
|
||||
character(len=*),parameter :: fmt2 = '(3(a,b32.32),i20)'
|
||||
|
||||
write(*,fmt1) 'input a=',a,' b=',b
|
||||
write(*,fmt2) 'and : ', a,' & ',b,' = ',iand(a, b),iand(a, b)
|
||||
write(*,fmt2) 'or : ', a,' | ',b,' = ',ior(a, b),ior(a, b)
|
||||
write(*,fmt2) 'xor : ', a,' ^ ',b,' = ',ieor(a, b),ieor(a, b)
|
||||
write(*,fmt2) 'lsh : ', a,' << ',b,' = ',ishft(a, abs(b)),ishft(a, abs(b))
|
||||
write(*,fmt2) 'rsh : ', a,' >> ',b,' = ',ishft(a, -abs(b)),ishft(a, -abs(b))
|
||||
write(*,fmt2) 'not : ', a,' ~ ',b,' = ',not(a),not(a)
|
||||
write(*,fmt2) 'rot : ', a,' r ',b,' = ',ishftc(a,-abs(b)),ishftc(a,-abs(b))
|
||||
|
||||
end subroutine bitwise
|
||||
|
||||
end program bits_rosetta
|
||||
8
Task/Bitwise-operations/Fortran/bitwise-operations-4.f
Normal file
8
Task/Bitwise-operations/Fortran/bitwise-operations-4.f
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
Input a= 14 b= 3
|
||||
AND : 00000000000000000000000000001110 & 00000000000000000000000000000011 = 00000000000000000000000000000010 2
|
||||
OR : 00000000000000000000000000001110 | 00000000000000000000000000000011 = 00000000000000000000000000001111 15
|
||||
XOR : 00000000000000000000000000001110 ^ 00000000000000000000000000000011 = 00000000000000000000000000001101 13
|
||||
LSH : 00000000000000000000000000001110 << 00000000000000000000000000000011 = 00000000000000000000000001110000 112
|
||||
RSH : 00000000000000000000000000001110 >> 00000000000000000000000000000011 = 00000000000000000000000000000001 1
|
||||
NOT : 00000000000000000000000000001110 ~ 00000000000000000000000000000011 = 11111111111111111111111111110001 -15
|
||||
ROT : 00000000000000000000000000001110 ~ 00000000000000000000000000000011 = 11000000000000000000000000000001 -1073741823
|
||||
Loading…
Add table
Add a link
Reference in a new issue