- Notifications
You must be signed in to change notification settings - Fork 198
Add stdlib_experimental_kinds.f90 and use it #63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
6 commits Select commit Hold shift + click to select a range
4a52299 Add stdlib_experimental_kinds.f90 and use it
certik 2375321 Update src/stdlib_experimental_kinds.f90
certik 4f8ff60 Update src/stdlib_experimental_kinds.f90
certik bd3067f Update Makefiles
certik 220421f Use it in stdlib_experimental_optval
certik 23e0b79 Switch to iso_fortran_env
certik File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add stdlib_experimental_kinds.f90 and use it
- Loading branch information
commit 4a52299a9e1cf1f1c9c73d229d2eab99a43f4c7d
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| module stdlib_experimental_kinds | ||
| ! Instead of iso_fortran_env, we use iso_c_binding, to be compatible with C | ||
| !use iso_fortran_env, only: sp=>real32, dp=>real64, qp=>real128 | ||
| !use iso_fortran_env, only: int32, int64, int128 | ||
| use iso_c_binding, only: sp=>c_float, dp=>c_double, qp=>c_float128 | ||
| use iso_c_binding, only: int32=>c_int32_t, int64=>c_int64_t, int128=>c_int128_t | ||
certik marked this conversation as resolved. Outdated Show resolved Hide resolved | ||
| implicit none | ||
| private | ||
| public sp, dp, qp, int32, int64, int128 | ||
certik marked this conversation as resolved. Outdated Show resolved Hide resolved | ||
| end module | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is
int128supported by all compilers?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a good question. If C has standardized
int128I would image that it is. But I need to consult the standard for more insight.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At least I don't find
c_int128_tiniso_c_binding orint128iniso_fortran_env`There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But it compiled. It might be only supported by gfortran?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The standard says that it will compile, but be set to a special value when not supported (missing) if my memory is correct. So compilation doesn't guarantee existence of the kind. (I think the special value is 0 or a negative integer.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like C99 has no guaranteed 128-bit integer (
long longis "at least 64 bits" andintN_tis only guaranteed up to 64).Looking at my own include files (libc 2.30), I don't see anything for 128-bit integers except a few places under an
__ILP32__preprocessor flag, which must have been unset when my platform-specific includes were preprocessed for my system.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, I think one does need to be careful with quad precision. On its own, it does not have a clear meaning. There are (at least) three active definitions:
https://gcc.gnu.org/onlinedocs/gcc/Floating-Types.html
For example, on my machine,
doubleandlong doubleboth point to_Float64. My libc also defines a_Float64xwhich as best I can tell corresponds to the x86 float80 format.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BTW I am looking at a copy of the 2018 standard now (Table 18.2 in section 18.3.1), and I don't see any reference to
c_int128_tin there? Only up toc_int64_t. Also no reference toc_float128.