unsigned variables in f77 ???

Calvin H. Vu calvin at dinkum.sgi.com
Tue Jun 12 04:33:49 AEST 1990


In article <6583 at vax1.acs.udel.EDU> mccalpin at vax1.acs.udel.EDU (John D Mccalpin) writes:

>I am working with lots of 8-bit image data that I want to transfer
>rapidly to the screen using an f77 program.  Since RECTWR wants
>16-bit data, I have to copy the 8-bit data to a 16-bit array.
>Unfortunately, f77 considers the 8-bit (integer*1) data to be 
>signed, and so it does sign extension in the transfer to the
>integer*2 array.  Is there any clean way of turning this off?
>(Without coding in C!)

>Anybody have any better ideas?

    The intrinsic function ichar() returns an unsigned byte result so if
    you do short(ichar(char(byte(n,n)))) you will get what you need.
    This is my simple test case:

	byte a
	character b
	a = -5
	b = char(-5)
	print 10, a, b, short(a), short(ichar(b)), short(ichar(char(a)))
10	format(2(z2,1x), 3(z4,1x))
	end

and this is the result I got:
FB FB FFFB   FB   FB

Unfortunately, this only works in our latest release (3.3 release) so you
can only do this trick if you have the latest release.

>John D. McCalpin                               mccalpin at vax1.udel.edu
>Assistant Professor                            mccalpin at delocn.udel.edu
>College of Marine Studies, U. Del.             mccalpin at scri1.scri.fsu.edu

--------------------------------------------------------------------------
Calvin H. Vu			   | "We are each of us angels with
Silicon Graphics Computer Systems  | only one wing.  And we can only
calvin at sgi.com   (415) 962-3679	   | fly embracing each other."



More information about the Comp.sys.sgi mailing list