-
Notifications
You must be signed in to change notification settings - Fork 1
Assignment Operator
Dionisis Pettas edited this page Dec 4, 2017
·
1 revision
Program Main
Use fString
Implicit None
Type(Str) :: MyStr
Integer :: Integ
Real(8) :: Double
!<><><><><><><><><><><><><><><><><><>
! Test 1: Integer = Type(Str)
! If Str is digit the Integer is equal
! to the digit else the return value
! is NaN
!<><><><><><><><><><><><><><><><><><>
Print*, 'Test 1:'
Print*, ''
MyStr = "22"
Integ = MyStr
Print*, Integ
!OutPut: 22
MyStr = "JustAName"
Integ = MyStr
Print*, Integ
!OutPut: -2147483648
Print*,'<><><><><><><><><><><><><><><><>'
Print*,''
!<><><><><><><><><><><><><><><><><><>
! Test 2: Type(Str) = Integer
!<><><><><><><><><><><><><><><><><><>
Print*, 'Test 2:'
Print*, ''
Integ = 2017
MyStr = Integ
Print*, MyStr
!OutPut: 2017
!<><><><><><><><><><><><><><><><><><>
! Test 3: Real(8) = Type(Str)
! If Str is numeric the real(8) is equal
! to the converted string else return
! is NaN
!<><><><><><><><><><><><><><><><><><>
Print*, 'Test 3:'
Print*, ''
MyStr = "22.d+2"
Double = MyStr
Print*, Double
!OutPut: 2200.00000000000
MyStr = "22..d+2"
Double = MyStr
Print*, Double
!OutPut: NaN
!<><><><><><><><><><><><><><><><><><>
! Test 4: Type(Str) = Real(8)
!<><><><><><><><><><><><><><><><><><>
Print*, 'Test 4:'
Print*, ''
Double = 1.d+3
MyStr = Double
Print*, MyStr
!OutPut: 1000.00000000000
End Program Main