comp.lang.ada
 help / color / mirror / Atom feed
From: dewar@cs.nyu.edu (Robert Dewar)
Subject: Re: Ada95 - Determining Machine Byte Order
Date: 5 Feb 1995 22:34:18 -0500
Date: 1995-02-05T22:34:18-05:00	[thread overview]
Message-ID: <3h45bq$fev@gnat.cs.nyu.edu> (raw)
In-Reply-To: 3gvudv$k4b@liberator.et.tudelft.nl

Not only is Mark's solution:

        int n = 1, little_endian = (*((char *)&n) == n);

not very clear (though if you study it for a second and can find your
way around * and & in C, you can see how it works), but more significantly
there is no guarantee that this will work, it is equivalent to the use of
unchecked conversion in Ada, and equally problematic. Mark if you don't
believe me, try seeing what this gives on a Cray, or if you want to take
the theoretical approach, tell me where in the ANSI standard it is written
that this will do something well defined.

All in all I think that the Ada way of doing things:

   Little_Endian : constant Boolean :=
        System.Default_Bit_Order = System.Low_Order_First;

maybe just a *little* bit clearer :-)





  parent reply	other threads:[~1995-02-06  3:34 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1995-02-02  4:47 Ada95 - Determining Machine Byte Order Timothy Halloran
     [not found] ` <3gvudv$k4b@liberator.et.tudelft.nl>
1995-02-06  3:34   ` Robert Dewar [this message]
1995-02-08 12:36     ` Mark de Rooi
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox