- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I had read that Fortran 95 and later support an UNSIGNED data type for unsigned integers. I successfully compiled a small program with gfortran with this type, but Intel Fortran does not seem to recognize it. Does Intel Fortran support unsigned integer types?
Jay
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You may be thinking of the Oracle Fortran extension.
ISHFT and other bitwise intrinsics have effects of unsigned operations.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Is there a standard 1-byte type that represents integer quantities from 0 - 255? (This is admittedly more of a general Fortran question.)
Thanks,
Jay
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
jayb wrote:
Is there a standard 1-byte type that represents integer quantities from 0 - 255? (This is admittedly more of a general Fortran question.)
Not really. Most compilers for platforms which have hardware support for 1-byte integers have a (most likely) signed integer of that storage size (f2008 KIND=int8). This could relatively easily be used to represent 0-255 by expressions like AND(INT(i1,KIND(1)),255), since the default integer kind surely will support positive integers larger than that, as well as negative ones. Most usage would require it to be widened anyway, as there would be at most a limited repertoire of hardware instructions for unsigned byte size arithmetic.
Even more widespread would be a CHARACTER of the closest available to that size, which can be used as a default integer by ICHAR intrinsic, if you're willing to take chances on (or be careful about) what happens with unexpected collating sequences.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The notion of an unsigned integer type, and also a bit type, has been extensively discussed amongst the Fortran standards committee. The majority of members voted to not add those to the language. There are bitwise functions - many commented that unsigned arithmetic led to many problems in C and they didn't want to introduce the same problems to Fortran.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page