Jump to content

Host introspection: Difference between revisions

Correction to non-portable code
No edit summary
(Correction to non-portable code)
Line 191:
=={{header|Fortran}}==
{{works with|Fortran|90 and later}}
<lang fortran>INTEGER, PARAMETER :: i8integer =:: SELECTED_INT_KIND(2)i
character(len=1) :: c(20)
INTEGER, PARAMETER :: i16 = SELECTED_INT_KIND(4)
equivalence (c, i)
INTEGER(i8) :: a(2)
INTEGER(i16) :: b
 
WRITE(*,*) bit_size(1) ! number of bits in the default integer type
! which may (or may not!) equal the word size
i = 1
 
IF (ichar(c(1)) == 0) THEN
b = Z'1234' ! Hexadecimal assignment
WRITE(*,*) "Big Endian"
a = (TRANSFER(b, a)) ! Split a 16 bit number into two 8 bit numbers
ELSE
 
WRITE(*,*) "Little Endian"
IF (a(1) == Z'12') THEN ! where did the most significant 8 bits end up
END IF</lang>
WRITE(*,*) "Big Endian"
ELSE
WRITE(*,*) "Little Endian"
END IF</lang>
 
=={{header|F_Sharp|F#}}==
Cookies help us deliver our services. By using our services, you agree to our use of cookies.