| <<< zur Fortran-Startseite | |
| << Fortran 95 | Fortran 2003 >> |
| < Arithmetische Ausdrücke | Vergleichsausdrücke > |
Logische Ausdrücke können zwei Zustände annehmen, .TRUE. oder .FALSE..
Logische Operatoren
| Operator | Kommentar |
|---|---|
| .NOT. | logisches NICHT |
| .AND. | logisches UND |
| .OR. | logisches ODER |
| .EQV. | logische Äquivalenz |
| .NEQV. | logische Antivalenz |
Wahrheitstafel
| a | b | .NOT. a | a .AND. b | a .OR. b | a .EQV. b | a .NEQV. b |
|---|---|---|---|---|---|---|
| .TRUE. | .TRUE. | .FALSE. | .TRUE. | .TRUE. | .TRUE. | .FALSE. |
| .TRUE. | .FALSE. | .FALSE. | .FALSE. | .TRUE. | .FALSE. | .TRUE. |
| .FALSE. | .TRUE. | .TRUE. | .FALSE. | .TRUE. | .FALSE. | .TRUE. |
| .FALSE. | .FALSE. | .TRUE. | .FALSE. | .FALSE. | .TRUE. | .FALSE. |
Beispiel:
| Fortran 90/95-Code (free source form) |
program bsp implicit none logical :: l l = .TRUE. write(*,*) .NOT. l ! Ausgabe: F end program bsp |
Beispiel:
| Fortran 90/95-Code (free source form) |
program bsp
implicit none
logical :: a, b
a = .TRUE.
b = .FALSE.
write (*,*) a .NEQV. b
! Ausgabe: T
end program bsp
|
Operatorenpriorität
- Klammerung () bindet am stärksten
.NOT..AND..OR..EQV., bzw..NEQV.
| <<< zur Fortran-Startseite | |
| << Fortran 95 | Fortran 2003 >> |
| < Arithmetische Ausdrücke | Vergleichsausdrücke > |
This article is issued from Wikibooks. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.