Unsigned 8 bits integer in Fortran

Unsigned 8 bits integer in Fortran


I need to work with images and I would like to know if there is a way to work with 8-bits unsigned integer in Fortran, with comparisons, additions,... I can't find a way to do that.


Best regards,


4 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Sun/Oracle Fortran, available for Linux and Solaris, has unsigned integers as a vendor extension.

If you want to use Intel Fortran, you should consider using, for example., C to write a few key functions that manipulate unsigned integers and call those functions/subroutines from Fortran.

You might perform unsigned arithmetic on integer(1) data type by promoting to a wider type and using e.g. and(i,z'ff') to zero out sign extension bits.  Is that one of your ways which doesn't work?

As mecej4 pointed out, you might use interoperable C functions to perform the arithmetic.  The signed vs. unsigned problem would not arise even though you declare it as a signed Fortran data type, as long as you don't perform arithmetic (including I/O conversions) in Fortran.


One could use ZEXT to zero-extend the value and compare that way.

Retired 12/31/2016

Leave a Comment

Please sign in to add a comment. Not a member? Join today