FIX: ISHFT and ISHL Always Assume 4-Byte Integers (111234)
The information in this article applies to:
- Microsoft FORTRAN PowerStation for MS-DOS 1.0
- Microsoft FORTRAN PowerStation for MS-DOS 1.0a
- Microsoft Fortran Powerstation 32 for Windows NT 1.0
This article was previously published under Q111234 SYMPTOMS
The ISHL and ISHFT intrinsic functions may return incorrect results when
shifting INTEGER*1 or INTEGER*2 variables. The incorrect results occur only
when right-shifting negative values.
CAUSE
The compiler converts the value to be shifted to a 4-byte value. For 1- and
2-byte negative integers, the higher order bits are filled with 1s, which
can be incorrectly shifted into the low order bytes.
RESOLUTION
Convert the bit pattern of the negative INTEGER*1 or INTEGER*2 value to an
unsigned INTEGER*4 value. This is done by adding 256 to a negative
INTEGER*1 value or by adding 65536 to a negative INTEGER*2 value. Then
shift the resulting INTEGER*4 value.
STATUS
Microsoft has confirmed this to be a problem in FORTRAN PowerStation 32 for
Windows NT version 1.0 and MS-DOS version 1.0 and 1.0a. This problem was
fixed in FORTRAN PowerStation 32, version 4.0.
Modification Type: | Major | Last Reviewed: | 10/17/2003 |
---|
Keywords: | kbbug kbfix kbLangFortran KB111234 |
---|
|