Jump to content

Host introspection: Difference between revisions

Equivalence statement is obsolete in Fortran 2018, so the version is one liner using the ISHFT intrinsic.
m (syntax highlighting fixup automation)
(Equivalence statement is obsolete in Fortran 2018, so the version is one liner using the ISHFT intrinsic.)
Line 387:
WRITE(*,*) "Little Endian"
END IF</syntaxhighlight>
{{works with|Fortran| 77 and later}}
<syntaxhighlight lang="fortran">
PROGRAM endianness
IMPLICIT NONE
INTEGER(KIND=4) :: i = 1
 
!ISHFT(INTEGER, SHIFT) : Left shift if SHIFT > 0
!ISHFT(INTEGER, SHIFT) : Right shift if SHIFT < 0
IF (ISHFT(i,1) .EQ. 0) THEN
WRITE(*,FMT='(A)') 'Architechture is Big Endian'
ELSE
WRITE(*,FMT='(A)') 'Architecture is Little Endian'
END IF
 
RETURN
 
STOP
END PROGRAM endianness
</syntaxhighlight>
 
=={{header|FreeBASIC}}==
3

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.