Path: utzoo!attcan!uunet!aplcen!uakari.primate.wisc.edu!zaphod.mps.ohio-state.edu!mips!sgi!shinobu!odin!dinkum!calvin From: calvin@dinkum.sgi.com (Calvin H. Vu) Newsgroups: comp.sys.sgi Subject: Re: unsigned variables in f77 ??? Keywords: integer*1, unsigned, two's complement Message-ID: <8809@odin.corp.sgi.com> Date: 11 Jun 90 18:33:49 GMT References: <6583@vax1.acs.udel.EDU> Sender: news@odin.corp.sgi.com Lines: 38 In article <6583@vax1.acs.udel.EDU> mccalpin@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@vax1.udel.edu >Assistant Professor mccalpin@delocn.udel.edu >College of Marine Studies, U. Del. mccalpin@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@sgi.com (415) 962-3679 | fly embracing each other."