Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!wuarchive!uunet!cbmvax!cbmehq!cbmfra!swinjm!forgeas From: forgeas@swinjm.UUCP (Jean-Michel Forgeas) Newsgroups: comp.sys.amiga.programmer Subject: Re: 4 bytes to a long? Message-ID: <19488689.ARN0eac@swinjm.UUCP> Date: 11 Jun 91 12:43:53 GMT References: <55908@nigel.ee.udel.edu> Reply-To: forgeas@swinjm.UUCP (Jean-Michel Forgeas) Followup-To: comp.sys.amiga.programmer Organization: The Software Winery Lines: 22 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 -- \___/ Jean-Michel Forgeas \-/ cbmvax!cbmehq!cbmfra!swinjm!forgeas | The Software Winery -^- And, where is the universe ?