Re: Layout Hell-o

From: Michael Wojcik (mwojcik_at_newsguy.com)
Date: 08/04/04


Date: 4 Aug 2004 16:28:03 GMT


In article <mCtPc.2238$hI.654797@newssvr28.news.prodigy.com>, "Michael Mattias" <michael.mattias@gte.net> writes:
> >
> > On 2-Aug-2004, "Michael Mattias" <michael.mattias@gte.net> wrote:
> >
> > > Incorrect: COBOL BINARY is big-endian (MSB at lowest address); C and
> > > BASIC
> > > have no such native datatype, as their BINARY integers are little-endian
> > > with MSB at highest address.
>
> The COBOL orientation is true on all platforms. Don't know about C/BASIC on
> 'nix or IBM mainframe, but on Windows machines the binary integer is in
> Intel order

The C standard requires that integral types use a "pure binary
numeration system" representation (ISO 9899-1990 6.1.2.5), with
various other restrictions, and in effect require one of sign-
magnitude, one's-complement, or two's-complement. I don't know of a
conforming implementation which uses anything other than two's-
complement. However, I don't believe there's any requirement that
the representation match the "native" pure binary representation used
by the platform - if there is one.

In practice, C implementations essentially always do use the native
integer representation, however, which means that they have big-endian
integers if the CPU uses big-endian integers. For Windows running on
a big-endian CPU (which was an option, once upon a time), C would use
big-endian integers. For Unix, C implementations are either big- or
little-endian depending on the CPU, usually; though for bimodal CPUs
the implementor has to choose the appropriate representation based on
the mode in which they expect the program to run.

There is occasional talk of adding endian-specific type support to C,
but insufficient interest exists to push it through the standard
committee, probably because C's bitwise operators make it trivial to
do the conversion, and utility macros and functions to do it are widely
available anyway. (And adding it to the C standard now would be an
exercise in futility, since few implementations have adopted the 1999
standard.)

As for BASIC - well, AFAIK, the dominant implementation of a language
calling itself "BASIC" doesn't follow any external standard anyway.

-- 
Michael Wojcik                  michael.wojcik@microfocus.com
Viewers are bugs for famous brands.
   -- unknown subtitler, Jackie Chan's _Thunderbolt_


Relevant Pages

  • Re: what is trap representation?
    ... > of 'trap representation'. ... If the stored value of an object has such a representation ... Some implementations will issue some kind of exception, such as a SIGFPE, ... and therefore not part of standard C. ...
    (comp.lang.c.moderated)
  • Re: How to convert Infix notation to postfix notation
    ... Which part of the C standard do you believe links C to the year 2038? ... POSIX does specify a representation in seconds ... implementations to provide time_t defined it as a signed 32-bit ... The standards didn't fix the problem, ...
    (comp.lang.c)
  • Re: Do loops until HUGE?
    ... bit of a pain as a result) for implementations to allow a negative ... typical implementation - not a distinction made by the standard. ... processor's representation). ... consistently work on all platforms. ...
    (comp.lang.fortran)
  • Re: Requesting advice how to clean up C code for validating string represents integer
    ... Linkname: c standard - clc-wiki ... with a signed zero (including all IEC 60559 implementations) ... that follow the specification of annex G, the sign of zero ... between brake pedal and brake pads being through a complicated ...
    (comp.lang.c)
  • Re: Storgae durations
    ... standard you referred to is no longer current. ... advocating C99 and saying that C90 is obsolete, ... Then you are in no position to make an argument about C99's portability ... there are implementations for C99 that target those platforms. ...
    (comp.lang.c)

Loading