Re: Binaries

*To*: mathgroup at smc.vnet.net*Subject*: [mg69763] Re: Binaries*From*: dh <dh at metrohm.ch>*Date*: Fri, 22 Sep 2006 01:04:43 -0400 (EDT)*References*: <eetuj3$9ls$1@smc.vnet.net>

Hi David, your question is not too clear. To you want to read from a file or do you want to convert from an n bits integer? What do you exactly mean by long: 32, 64, 128 bits? Further, I assume you are talking about integers. Now do the three bytes repesent 1 or 3 numbers? 1) Assuming the three bytes code for one number and the long has 32 bits and you want to read from a file. In this case, you can simply read the whole 32 integer by: BinaryReadList[stream,"Integer32"]; see manual 2) If the three bytes are 3 different numbers, and you want to read from a file written with 32 bits integres, you need to read every single byte and throw away the superfluos byte: t=BinaryReadList[stream,"Integer8"] t=Partition[t,4]; t=Drop[t,{},1] 3) In case you want to convert Integers, you may use Bit Operators like BitAnd,BitOr,.. ,see manual or: Developer`BitShiftLeft/Right Daniel David.MartinyMarero at uam.es wrote: > Dear sirs, > > How can I read binary numbers with the format: three bytes placed in a > long? > > Thanks, > > D- >