This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: BOZ question
On Monday 21 February 2005 16:04, Steve Kargl wrote:
> On Mon, Feb 21, 2005 at 09:02:43AM +0100, FX Coudert wrote:
> > >What value is assigned to i1 and what is the proper value?
> > >integer(1), parameter :: i1 = b'10000001'
> >
> > All compilers at hand (including gfortran) say -127, but this seems to
> > simple an answer so I guess I must have misunderstood the question...
>
> Yes, that is what gfortran gives. I wasn't expecting the
> twos complement of the binary number. While writing a
> testsuite program to test BOZ, I set i1=b'00000001', which
> is 1. I, then, naively set the sign bit expecting -1.
The binary representation of negative numbers is not defined by the standard.
I expect pretty much every compiler still in existence uses two's complement
representation, though other representations (eg. sign+magnitude) are
allowed.
Paul