> Date: Fri, 2 Mar 2001 15:02:44 CST
> From: Shyan Lam <[log in to unmask]>
> Hi,
>
> First of all, I don't think Fortran support unsigned integers. In general, a
> signed number uses its most-significant-bit (msb) as sign bit but a unsigned
> number does not.
A signed integer does not, in general, use a sign bit.
Twos complement and ones complement systems do not.
Only in the signed magnitude convention is there a sign bit.
In the ones and twos complement notations the most-significant
bit is 0 for a positive integer and 1 for a negative integer.
On computers, twos complement notation is typically used for integers.
Addition and subtraction for unsigned integers produces te same bit pattern
as for signed (twos complement notation).
In Fortran, it's possible to introduce a type for unsigned integers.
One needs to introduce special integer-to-string conversion (and vice versa)
for unsigned integers in order to display and to input unsigned integers
up to the maximum value.
> Therefore if the value of the unsigned number happen to set
> the sign bit, the resulting value when viewed as a signed integer will be
> negative.
>
> Shyan,
=====================================
> Aleksandar Donev <[log in to unmask]> wrote:
> > Hi,
> >
> > This is probably an old question, but someone just asked me this and I had
> > no clue. Do any Fortran compilers support unsigned integers of any kind?
> > How? My manual for Lahey has a chapter on interfacing with C but it simply
> > does not include unsigned in its tables. I am not sure what the C standard
> > says on unsigned and how that would translate into the number model of
> > Fortran.
> >
> > Thanks,
> > Aleksandar
> > _____________________________________________
> > Aleksandar Donev
> > http://www.pa.msu.edu/~donev/
> > [log in to unmask]
> > (517) 432-6770
> > Department of Physics and Astronomy
> > Michigan State University
> > East Lansing, MI 48824-1116
> > _____________________________________________
>
>
> ____________________________________________________________________
> Get free email and a permanent address at http://www.netaddress.com/?N=1
>
|