Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

UNSIGNED type?

jayb
Débutant
1 250 Visites

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

 

 

0 Compliments
4 Réponses
TimP
Contributeur émérite III
1 250 Visites

You may be thinking of the Oracle Fortran extension.

ISHFT and other bitwise intrinsics have effects of unsigned operations.

0 Compliments
jayb
Débutant
1 250 Visites

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

 

 

 

0 Compliments
TimP
Contributeur émérite III
1 250 Visites

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.

0 Compliments
Steven_L_Intel1
Employé
1 250 Visites

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.

0 Compliments
Répondre