1<!--===- docs/IntrinsicTypes.md 2 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 6 7--> 8 9# Implementation of `Intrinsic` types in f18 10 11```eval_rst 12.. contents:: 13 :local: 14``` 15 16Intrinsic types are integer, real, complex, character, and logical. 17All intrinsic types have a kind type parameter called KIND, 18which determines the representation method for the specified type. 19The intrinsic type character also has a length type parameter called LEN, 20which determines the length of the character string. 21 22The implementation of `CHARACTER` type in f18 is described 23in [Character.md](Character.md). 24 25## Supported TYPES and KINDS 26 27Here are the type and kind combinations supported in f18: 28 29INTEGER(KIND=1) 8-bit two's-complement integer 30INTEGER(KIND=2) 16-bit two's-complement integer 31INTEGER(KIND=4) 32-bit two's-complement integer 32INTEGER(KIND=8) 64-bit two's-complement integer 33INTEGER(KIND=16) 128-bit two's-complement integer 34 35REAL(KIND=2) 16-bit IEEE 754 binary16 (5e11m) 36REAL(KIND=3) 16-bit upper half of 32-bit IEEE 754 binary32 (8e8m) 37REAL(KIND=4) 32-bit IEEE 754 binary32 (8e24m) 38REAL(KIND=8) 64-bit IEEE 754 binary64 (11e53m) 39REAL(KIND=10) 80-bit extended precision with explicit normalization bit (15e64m) 40REAL(KIND=16) 128-bit IEEE 754 binary128 (15e113m) 41 42COMPLEX(KIND=2) Two 16-bit IEEE 754 binary16 43COMPLEX(KIND=3) Two 16-bit upper half of 32-bit IEEE 754 binary32 44COMPLEX(KIND=4) Two 32-bit IEEE 754 binary32 45COMPLEX(KIND=8) Two 64-bit IEEE 754 binary64 46COMPLEX(KIND=10) Two 80-bit extended precisions values 47COMPLEX(KIND=16) Two 128-bit IEEE 754 binary128 48 49No 50[double-double 51](https://en.wikipedia.org/wiki/Quadruple-precision_floating-point_format) 52quad precision type is supported. 53 54LOGICAL(KIND=1) 8-bit integer 55LOGICAL(KIND=2) 16-bit integer 56LOGICAL(KIND=4) 32-bit integer 57LOGICAL(KIND=8) 64-bit integer 58 59No 128-bit logical support. 60 61### Defaults kinds 62 63INTEGER 4 64REAL 4 65COMPLEX 4 66DOUBLE PRECISION 8 67LOGICAL 4 68 69#### Modifying the default kind with default-real-8. 70REAL 8 71DOUBLE PRECISION 8 72COMPLEX 8 73 74#### Modifying the default kind with default-integer-8: 75INTEGER 8 76 77There is no option to modify the default logical kind. 78 79Modules compiled with different default-real and default-integer kinds 80may be freely mixed. 81Module files encode the kind value for every entity. 82 83## Representation of LOGICAL variables 84 85The default logical is `LOGICAL(KIND=4)`. 86 87Logical literal constants with kind 1, 2, 4, and 8 88share the following characteristics: 89.TRUE. is represented as 1_kind 90.FALSE. is represented as 0_kind 91 92Tests for true is *integer value is not zero*. 93 94The implementation matches gfortran. 95 96Programs should not use integer values in LOGICAL contexts or 97use LOGICAL values to interface with other languages. 98 99### Representations of LOGICAL variables in other compilers 100 101##### Intel ifort / NVIDA nvfortran / PGI pgf90 102.TRUE. is represented as -1_kind 103.FALSE. is represented as 0_kind 104Any other values result in undefined behavior. 105 106Values with a low-bit set are treated as .TRUE.. 107Values with a low-bit clear are treated as .FALSE.. 108 109##### IBM XLF 110.TRUE. is represented as 1_kind 111.FALSE. is represented as 0_kind 112 113Values with a low-bit set are treated as .TRUE.. 114Values with a low-bit clear are treated as .FALSE.. 115