Newsgroups: comp.sys.amiga.programmer
Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!sol.ctr.columbia.edu!ira.uka.de!news
From: S_ASCHMIDT@iravcl.ira.uka.de (|S| Angela Schmidt)
Subject: Re: 4 bytes to a long?
In-Reply-To: forgeas@swinjm.UUCP's message of 11 Jun 91 12: 43:53 GMT
Message-ID: <1991Jun12.144601.4340@ira.uka.de>
Sender: news@ira.uka.de (USENET News System)
Organization: University of Karlsruhe, FRG (Informatik Rechnerabteilung)
References: <55908@nigel.ee.udel.edu> <19488689.ARN0eac@swinjm.UUCP>
Date: Wed, 12 Jun 1991 15:41:52 GMT
X-News-Reader: VMS NEWS 1.08
Lines: 37

In <19488689.ARN0eac@swinjm.UUCP> forgeas@swinjm.UUCP writes:

> In article <55908@nigel.ee.udel.edu>, jleonard@pica.army.mil writes:
> 
> > mrimages@beach.gal.utexas.edu in <451.28517f01@beach.gal.utexas.edu> write:
> >               Is there a fast, simple way to convert 4 bytes into a long?
> >
> > I use :
> >
> > char ch[4];
> > long l;
> >
> > memcpy( (char *)&l, ch, sizeof(long));
> 
> To convert four bytes into a long:
>     l = *((long*) ch)
> This will generate only one instruction:
>     move.l _ch,_l
> --

Oh no! Please don't do this!!!! What will happen if the field of characters
begins at an odd address? The 68020 and higher will do this. But all others
will crash. The chance that the machine survives is about 50% only. Please,
please don't use this conversion!!!

>                                      \___/
> Jean-Michel Forgeas                   \-/
> cbmvax!cbmehq!cbmfra!swinjm!forgeas    |    The Software Winery
>                                       -^-
>                            And, where is the universe ?

---------------------------------------------------------+---------------------
Angela Schmidt   Internet: S_ASchmidt@iravcl.ira.uka.de  |        //
(Nessy in IRC)   BITNET:   UK8B@DKAUNI2.BITNET           | Amiga //
                 Phone:    +49 731 712316 & 721 6904-263 |   \\ // only 1000
                           MEZ: (10am-9pm)  (12pm-10pm)  |    \X/ the real one!
---------------------------------------------------------+---------------------
