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

Unsigned 8 bits integer in Fortran

velvia
Beginner
2,117 Views

Hi,

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,

François

0 Kudos
3 Replies
mecej4
Honored Contributor III
2,117 Views

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.

0 Kudos
TimP
Honored Contributor III
2,117 Views

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.

 

0 Kudos
Steven_L_Intel1
Employee
2,117 Views

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

0 Kudos
Reply