1 <!--===- docs/IntrinsicTypes.md
3 Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 See https://llvm.org/LICENSE.txt for license information.
5 SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
9 # Implementation of `Intrinsic` types in f18
16 Intrinsic types are integer, real, complex, character, and logical.
17 All intrinsic types have a kind type parameter called KIND,
18 which determines the representation method for the specified type.
19 The intrinsic type character also has a length type parameter called LEN,
20 which determines the length of the character string.
22 The implementation of `CHARACTER` type in f18 is described
23 in [Character.md](Character.md).
25 ## Supported TYPES and KINDS
27 Here are the type and kind combinations supported in f18:
29 INTEGER(KIND=1) 8-bit two's-complement integer
30 INTEGER(KIND=2) 16-bit two's-complement integer
31 INTEGER(KIND=4) 32-bit two's-complement integer
32 INTEGER(KIND=8) 64-bit two's-complement integer
33 INTEGER(KIND=16) 128-bit two's-complement integer
35 REAL(KIND=2) 16-bit IEEE 754 binary16 (5e11m)
36 REAL(KIND=3) 16-bit upper half of 32-bit IEEE 754 binary32 (8e8m)
37 REAL(KIND=4) 32-bit IEEE 754 binary32 (8e24m)
38 REAL(KIND=8) 64-bit IEEE 754 binary64 (11e53m)
39 REAL(KIND=10) 80-bit extended precision with explicit normalization bit (15e64m)
40 REAL(KIND=16) 128-bit IEEE 754 binary128 (15e113m)
42 COMPLEX(KIND=2) Two 16-bit IEEE 754 binary16
43 COMPLEX(KIND=3) Two 16-bit upper half of 32-bit IEEE 754 binary32
44 COMPLEX(KIND=4) Two 32-bit IEEE 754 binary32
45 COMPLEX(KIND=8) Two 64-bit IEEE 754 binary64
46 COMPLEX(KIND=10) Two 80-bit extended precisions values
47 COMPLEX(KIND=16) Two 128-bit IEEE 754 binary128
51 ](https://en.wikipedia.org/wiki/Quadruple-precision_floating-point_format)
52 quad precision type is supported.
54 LOGICAL(KIND=1) 8-bit integer
55 LOGICAL(KIND=2) 16-bit integer
56 LOGICAL(KIND=4) 32-bit integer
57 LOGICAL(KIND=8) 64-bit integer
59 No 128-bit logical support.
69 #### Modifying the default kind with default-real-8.
74 #### Modifying the default kind with default-integer-8:
77 There is no option to modify the default logical kind.
79 Modules compiled with different default-real and default-integer kinds
81 Module files encode the kind value for every entity.
83 ## Representation of LOGICAL variables
85 The default logical is `LOGICAL(KIND=4)`.
87 Logical literal constants with kind 1, 2, 4, and 8
88 share the following characteristics:
89 .TRUE. is represented as 1_kind
90 .FALSE. is represented as 0_kind
92 Tests for true is *integer value is not zero*.
94 The implementation matches gfortran.
96 Programs should not use integer values in LOGICAL contexts or
97 use LOGICAL values to interface with other languages.
99 ### Representations of LOGICAL variables in other compilers
101 ##### Intel ifort / NVIDA nvfortran / PGI pgf90
102 .TRUE. is represented as -1_kind
103 .FALSE. is represented as 0_kind
104 Any other values result in undefined behavior.
106 Values with a low-bit set are treated as .TRUE..
107 Values with a low-bit clear are treated as .FALSE..
110 .TRUE. is represented as 1_kind
111 .FALSE. is represented as 0_kind
113 Values with a low-bit set are treated as .TRUE..
114 Values with a low-bit clear are treated as .FALSE..