<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Convert an int to a byte array  in Intel® Integrated Performance Primitives</title>
    <link>https://community.intel.com/t5/Intel-Integrated-Performance/Convert-an-int-to-a-byte-array/m-p/888472#M11098</link>
    <description>&lt;DIV style="margin:0px;"&gt;&lt;/DIV&gt;
&lt;P&gt;With fread you can't specify to read 4-bytes varaible as big-endian or little-endian value. So you have to think on arhitecture you are running on and on format of the data you read (and how to interpret them) by yourself.&lt;/P&gt;
&lt;P&gt;Vladimir&lt;/P&gt;</description>
    <pubDate>Thu, 11 Dec 2008 08:47:45 GMT</pubDate>
    <dc:creator>Vladimir_Dudnik</dc:creator>
    <dc:date>2008-12-11T08:47:45Z</dc:date>
    <item>
      <title>Convert an int to a byte array</title>
      <link>https://community.intel.com/t5/Intel-Integrated-Performance/Convert-an-int-to-a-byte-array/m-p/888464#M11090</link>
      <description>&lt;P&gt;Does Intel has a fast routine for converting a 4 byteint and 4 byte float to a 4 byte byte array &lt;BR /&gt;and back?&lt;/P&gt;
&lt;P&gt;Thanks in advance,&lt;BR /&gt;Constantine&lt;/P&gt;</description>
      <pubDate>Sat, 06 Dec 2008 05:36:23 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Integrated-Performance/Convert-an-int-to-a-byte-array/m-p/888464#M11090</guid>
      <dc:creator>constantine-vassilev</dc:creator>
      <dc:date>2008-12-06T05:36:23Z</dc:date>
    </item>
    <item>
      <title>Re: Convert an int to a byte array</title>
      <link>https://community.intel.com/t5/Intel-Integrated-Performance/Convert-an-int-to-a-byte-array/m-p/888465#M11091</link>
      <description>&lt;DIV style="margin:0px;"&gt;
&lt;DIV id="quote_reply" style="width: 100%; margin-top: 5px;"&gt;
&lt;DIV style="margin-left:2px;margin-right:2px;"&gt;Quoting - &lt;A href="https://community.intel.com/en-us/profile/408384"&gt;thstart&lt;/A&gt;&lt;/DIV&gt;
&lt;DIV style="background-color:#E5E5E5; padding:5px;border: 1px; border-style: inset;margin-left:2px;margin-right:2px;"&gt;&lt;EM&gt;
&lt;P&gt;Does Intel has a fast routine for converting a 4 byteint and 4 byte float to a 4 byte byte array &lt;BR /&gt;and back?&lt;/P&gt;
&lt;P&gt;Thanks in advance,&lt;BR /&gt;Constantine&lt;/P&gt;
&lt;/EM&gt;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;Hi Constantine,&lt;/P&gt;
&lt;P&gt;I'm probably missing something, but why not use the old fashioned memcpy ? E.g. :&lt;/P&gt;
&lt;P&gt;int i = 0x12345678;&lt;BR /&gt; BYTE B[4];&lt;BR /&gt; memcpy(B, &amp;amp;i, 4);&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Rob&lt;/P&gt;</description>
      <pubDate>Mon, 08 Dec 2008 14:56:16 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Integrated-Performance/Convert-an-int-to-a-byte-array/m-p/888465#M11091</guid>
      <dc:creator>Rob_Ottenhoff</dc:creator>
      <dc:date>2008-12-08T14:56:16Z</dc:date>
    </item>
    <item>
      <title>Re: Convert an int to a byte array</title>
      <link>https://community.intel.com/t5/Intel-Integrated-Performance/Convert-an-int-to-a-byte-array/m-p/888466#M11092</link>
      <description>&lt;DIV style="margin:0px;"&gt;I would say there are cases when no conversion is required. For example,&lt;/DIV&gt;
&lt;DIV style="margin:0px;"&gt;int a;&lt;/DIV&gt;
&lt;DIV style="margin:0px;"&gt;unsigned char* p = &amp;amp;a;&lt;/DIV&gt;
&lt;DIV style="margin:0px;"&gt;now you can access a[0], a[1], a[2] and a[3] as a bytes. Be careful though to not change bytes on stack outside of this integer variable.&lt;/DIV&gt;
&lt;DIV style="margin:0px;"&gt;Vladimir&lt;/DIV&gt;
&lt;DIV style="margin:0px;"&gt;&lt;/DIV&gt;
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 09 Dec 2008 13:48:50 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Integrated-Performance/Convert-an-int-to-a-byte-array/m-p/888466#M11092</guid>
      <dc:creator>Vladimir_Dudnik</dc:creator>
      <dc:date>2008-12-09T13:48:50Z</dc:date>
    </item>
    <item>
      <title>Re: Convert an int to a byte array</title>
      <link>https://community.intel.com/t5/Intel-Integrated-Performance/Convert-an-int-to-a-byte-array/m-p/888467#M11093</link>
      <description>&lt;DIV style="margin:0px;"&gt;
&lt;DIV id="quote_reply" style="margin-top: 5px; width: 100%;"&gt;
&lt;DIV style="margin-left:2px;margin-right:2px;"&gt;Quoting - &lt;A href="https://community.intel.com/en-us/profile/61463"&gt;vdudnik&lt;/A&gt;&lt;/DIV&gt;
&lt;DIV style="background-color:#E5E5E5; padding:5px;border: 1px; border-style: inset;margin-left:2px;margin-right:2px;"&gt;&lt;EM&gt;
&lt;DIV style="margin:0px;"&gt;I would say there are cases when no conversion is required. For example,&lt;/DIV&gt;
&lt;DIV style="margin:0px;"&gt;int a;&lt;/DIV&gt;
&lt;DIV style="margin:0px;"&gt;unsigned char* p = &amp;amp;a;&lt;/DIV&gt;
&lt;DIV style="margin:0px;"&gt;now you can access a[0], a[1], a[2] and a[3] as a bytes. Be careful though to not change bytes on stack outside of this integer variable.&lt;/DIV&gt;
&lt;DIV style="margin:0px;"&gt;Vladimir&lt;/DIV&gt;
&lt;P&gt;&lt;/P&gt;
&lt;/EM&gt;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;&lt;BR /&gt;&lt;SPAN style="font-size: x-small;"&gt;
&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;The reason I need this is thatI am creating buffered in memoryLZO compression which to be flushed to disk when needed. To do that I have to store the length of the uncompressed source&lt;BR /&gt;and also the length of compressed source.&lt;/P&gt;
&lt;P&gt;Here is the problem. ippsEncodeLZO_8u uses byte array to store the compressed information.&lt;BR /&gt;I know the source length in advance, ippsEncodeLZO_8u returns destination (compressed)&lt;BR /&gt;length which has to be stored in the beginning of the byte array so the decompression to be able&lt;BR /&gt;to work later: &lt;SPAN style="font-size: x-small;"&gt;ippsDecodeLZO_8u. EncodeLZO and DecodeLZO need these 2 lengths as Ipp32utypes - e.g. 4 bytes.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;What follows I need to store in beginning of the buffertwo Ipp32u valuesof 4 bytes each and be able to read them later as Ipp32u. The difficulties I see is there is not easy way to save these Ipp32u values as 4 separate bytes as is andread them back directly as Ipp32u. I wroteBig Endian Split routine for splitting the Ipp32u to 4 separate bytes and then again use Big Endian Unsplit routine to read and interpret them back as Ipp32u.&lt;/P&gt;
&lt;P&gt;But this adds additional compexyty. What I need is to be able to write and read directly in Ipp32u.&lt;BR /&gt;For example writing to file this is possible:&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: x-small;"&gt;&lt;SPAN style="font-size: x-small;"&gt;&lt;SPAN style="font-size: x-small;"&gt;&lt;FONT size="2"&gt;&lt;FONT size="2"&gt;
&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Ipp32u srcLen;&lt;/P&gt;
&lt;BR /&gt;size=&lt;FONT size="2"&gt;
&lt;P&gt;&lt;BR /&gt;size=&lt;/P&gt;
&lt;/FONT&gt;
&lt;P&gt;&lt;SPAN style="font-size: x-small; color: #0000ff;"&gt;&lt;SPAN style="font-size: x-small; color: #0000ff;"&gt;sizeof&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: x-small;"&gt;(srcLen);&lt;/SPAN&gt;&lt;BR /&gt;fwrite(&amp;amp;srcLen, 1, size, pOutBin);&lt;BR /&gt;&lt;BR /&gt;As you see you can save Ipp32u value directly to the file which is actually a byte array.&lt;/P&gt;
&lt;P&gt;You can read this value back later as Ipp32u directly.&lt;/P&gt;
&lt;FONT size="2"&gt;
&lt;P&gt;&lt;SPAN style="font-size: x-small;"&gt;
&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Ipp32u srcLen;&lt;BR /&gt;size=&lt;SPAN style="font-size: x-small; color: #0000ff;"&gt;&lt;SPAN style="font-size: x-small; color: #0000ff;"&gt;sizeof&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: x-small;"&gt;(srcLen);&lt;/SPAN&gt;&lt;BR /&gt;fread(&amp;amp;srcLen, 1, size, pIn);&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;FONT size="2"&gt;&lt;FONT size="2"&gt;
&lt;P&gt;Best,&lt;/P&gt;
&lt;/FONT&gt;&lt;/FONT&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;/FONT&gt;&lt;P&gt;&lt;/P&gt;
&lt;P&gt;
&lt;/P&gt;&lt;P&gt;Constantine&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Dec 2008 18:52:57 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Integrated-Performance/Convert-an-int-to-a-byte-array/m-p/888467#M11093</guid>
      <dc:creator>constantine-vassilev</dc:creator>
      <dc:date>2008-12-10T18:52:57Z</dc:date>
    </item>
    <item>
      <title>Re: Convert an int to a byte array</title>
      <link>https://community.intel.com/t5/Intel-Integrated-Performance/Convert-an-int-to-a-byte-array/m-p/888468#M11094</link>
      <description>&lt;DIV style="margin: 0px; height: auto;"&gt;&lt;/DIV&gt;
&lt;DIV style="margin:0px;"&gt;Depending on your target machine, if it is little-endian (like Intel architecture) and you want to keep multi-byte values in big-endian format you have to have byte swapping. If you can keep values in little-endian format youdo not have todo byte swapping.&lt;/DIV&gt;
&lt;DIV style="margin:0px;"&gt;By the way, there is ippsByteSwap function in IPP&lt;/DIV&gt;
&lt;DIV style="margin:0px;"&gt;Vladimir&lt;/DIV&gt;
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Dec 2008 19:12:28 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Integrated-Performance/Convert-an-int-to-a-byte-array/m-p/888468#M11094</guid>
      <dc:creator>Vladimir_Dudnik</dc:creator>
      <dc:date>2008-12-10T19:12:28Z</dc:date>
    </item>
    <item>
      <title>Re: Convert an int to a byte array</title>
      <link>https://community.intel.com/t5/Intel-Integrated-Performance/Convert-an-int-to-a-byte-array/m-p/888469#M11095</link>
      <description>&lt;DIV style="margin:0px;"&gt;
&lt;DIV id="quote_reply" style="margin-top: 5px; width: 100%;"&gt;
&lt;DIV style="margin-left:2px;margin-right:2px;"&gt;Quoting - &lt;A href="https://community.intel.com/en-us/profile/61463"&gt;vdudnik&lt;/A&gt;&lt;/DIV&gt;
&lt;DIV style="background-color:#E5E5E5; padding:5px;border: 1px; border-style: inset;margin-left:2px;margin-right:2px;"&gt;&lt;EM&gt;
&lt;DIV style="margin:0px;"&gt;Depending on your target machine, if it is little-endian (like Intel architecture) and you want to keep multi-byte values in big-endian format you have to have byte swapping. If you can keep values in little-endian format youdo not have todo byte swapping.&lt;/DIV&gt;
&lt;DIV style="margin:0px;"&gt;By the way, there is ippsByteSwap function in IPP&lt;/DIV&gt;
&lt;DIV style="margin:0px;"&gt;Vladimir&lt;/DIV&gt;
&lt;P&gt;&lt;/P&gt;
&lt;/EM&gt;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;&lt;BR /&gt;&lt;SPAN style="font-size: small;"&gt;&lt;SPAN style="font-size: x-small;"&gt;So - the bottom line - how is the best way to write/read &lt;/SPAN&gt;
&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: x-small;"&gt;&lt;SPAN style="font-size: x-small;"&gt;Ipp32u type as a byte array on Intel machines&lt;/SPAN&gt;?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Dec 2008 19:26:47 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Integrated-Performance/Convert-an-int-to-a-byte-array/m-p/888469#M11095</guid>
      <dc:creator>constantine-vassilev</dc:creator>
      <dc:date>2008-12-10T19:26:47Z</dc:date>
    </item>
    <item>
      <title>Re: Convert an int to a byte array</title>
      <link>https://community.intel.com/t5/Intel-Integrated-Performance/Convert-an-int-to-a-byte-array/m-p/888470#M11096</link>
      <description>&lt;DIV style="margin:0px;"&gt;Again, depends on how that 4-byte variable is stored. If it is stored in big-endian format you have to byte swapping. You may call fread first to get 4 bytes and then swap them in little endian format. You also may call fread for each byte separately and progressively construct your little-endian value. In any case, usually it is only needed at some header parse code which rarely takes more than 5% of the whole decoding time in codecs (does not really matter what codecs, this is consistant for JPEG, MPEG, H.264 and so on). Do you think it is time critical part of LZO compression?&lt;/DIV&gt;
&lt;DIV style="margin:0px;"&gt;Vladimir&lt;/DIV&gt;
&lt;DIV style="margin:0px;"&gt;&lt;/DIV&gt;
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Dec 2008 19:33:54 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Integrated-Performance/Convert-an-int-to-a-byte-array/m-p/888470#M11096</guid>
      <dc:creator>Vladimir_Dudnik</dc:creator>
      <dc:date>2008-12-10T19:33:54Z</dc:date>
    </item>
    <item>
      <title>Re: Convert an int to a byte array</title>
      <link>https://community.intel.com/t5/Intel-Integrated-Performance/Convert-an-int-to-a-byte-array/m-p/888471#M11097</link>
      <description>&lt;DIV style="margin:0px;"&gt;
&lt;DIV id="quote_reply" style="margin-top: 5px; width: 100%;"&gt;
&lt;DIV style="margin-left:2px;margin-right:2px;"&gt;Quoting - &lt;A href="https://community.intel.com/en-us/profile/61463"&gt;vdudnik&lt;/A&gt;&lt;/DIV&gt;
&lt;DIV style="background-color:#E5E5E5; padding:5px;border: 1px; border-style: inset;margin-left:2px;margin-right:2px;"&gt;&lt;EM&gt;
&lt;DIV style="margin:0px;"&gt;Again, depends on how that 4-byte variable is stored. If it is stored in big-endian format you have to byte swapping. You may call fread first to get 4 bytes and then swap them in little endian format. You also may call fread for each byte separately and progressively construct your little-endian value. In any case, usually it is only needed at some header parse code which rarely takes more than 5% of the whole decoding time in codecs (does not really matter what codecs, this is consistant for JPEG, MPEG, H.264 and so on). Do you think it is time critical part of LZO compression?&lt;/DIV&gt;
&lt;DIV style="margin:0px;"&gt;Vladimir&lt;/DIV&gt;
&lt;P&gt;&lt;/P&gt;
&lt;/EM&gt;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;&lt;BR /&gt;fread and fwrite is disk related. With fread and fwrite I can specify howto interpret these 4 bytes. In my case I interpret them as Ipp32u, but really they are saved as 4 bytes.I want to do the same in the memory. &lt;SPAN style="font-size: x-small;"&gt;
&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;e.g. the variable is Ipp32u = 4 bytes. The question is how to store these 4 bytes in Ipp8u&lt;BR /&gt;memory array, so to be able to readthese 4 byteslater directly as Ipp32u variable.&lt;BR /&gt;This Ipp8u memory array can be saved as a binary file and the first 4 bytes read later &lt;BR /&gt;with fread as an Ipp32u variable.&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Dec 2008 06:43:52 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Integrated-Performance/Convert-an-int-to-a-byte-array/m-p/888471#M11097</guid>
      <dc:creator>constantine-vassilev</dc:creator>
      <dc:date>2008-12-11T06:43:52Z</dc:date>
    </item>
    <item>
      <title>Re: Convert an int to a byte array</title>
      <link>https://community.intel.com/t5/Intel-Integrated-Performance/Convert-an-int-to-a-byte-array/m-p/888472#M11098</link>
      <description>&lt;DIV style="margin:0px;"&gt;&lt;/DIV&gt;
&lt;P&gt;With fread you can't specify to read 4-bytes varaible as big-endian or little-endian value. So you have to think on arhitecture you are running on and on format of the data you read (and how to interpret them) by yourself.&lt;/P&gt;
&lt;P&gt;Vladimir&lt;/P&gt;</description>
      <pubDate>Thu, 11 Dec 2008 08:47:45 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Integrated-Performance/Convert-an-int-to-a-byte-array/m-p/888472#M11098</guid>
      <dc:creator>Vladimir_Dudnik</dc:creator>
      <dc:date>2008-12-11T08:47:45Z</dc:date>
    </item>
    <item>
      <title>Re: Convert an int to a byte array</title>
      <link>https://community.intel.com/t5/Intel-Integrated-Performance/Convert-an-int-to-a-byte-array/m-p/888473#M11099</link>
      <description>&lt;DIV style="margin:0px;"&gt;
&lt;DIV id="quote_reply" style="width: 100%; margin-top: 5px;"&gt;
&lt;DIV style="margin-left:2px;margin-right:2px;"&gt;Quoting - &lt;A href="https://community.intel.com/en-us/profile/408384"&gt;thstart&lt;/A&gt;&lt;/DIV&gt;
&lt;DIV style="background-color:#E5E5E5; padding:5px;border: 1px; border-style: inset;margin-left:2px;margin-right:2px;"&gt;&lt;EM&gt;
&lt;DIV style="margin:0px;"&gt;&lt;/DIV&gt;
&lt;P&gt;What follows I need to store in beginning of the buffertwo Ipp32u valuesof 4 bytes each and be able to read them later as Ipp32u.&lt;/P&gt;
&lt;/EM&gt;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;Constantine, there are so many ways to implement this... Below is an example with "unsigned int". The same will be with Ipp32u.&lt;/P&gt;
&lt;P&gt;unsigned char buffer[1000];&lt;BR /&gt; unsigned int *size1 = (unsigned int*)buffer;&lt;BR /&gt; unsigned int *size2 = (unsigned int*)(buffer+sizeof(unsigned int));&lt;BR /&gt; *size1 = 100;&lt;BR /&gt; *size2 = 200;&lt;BR /&gt; unsigned char *myStorage=buffer+2*sizeof(unsigned int);&lt;BR /&gt; unsigned int myLength = (unsigned int)(sizeof(buffer)-(myStorage-buffer));&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;You can use memcpy:&lt;BR /&gt; unsigned int size1 = 100;&lt;BR /&gt; unsigned int size2 = 200;&lt;BR /&gt; memcpy(buffer, &amp;amp;size1, sizeof(unsigned int));&lt;BR /&gt; memcpy(buffer+sizeof(unsigned int), &amp;amp;size2, sizeof(unsigned int));&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Exotic:&lt;BR /&gt; union {&lt;BR /&gt; unsigned char buffer[1000];&lt;BR /&gt; struct {&lt;BR /&gt; unsigned int _size1;&lt;BR /&gt; unsigned int _size2;&lt;BR /&gt; } sizes;&lt;BR /&gt; } myStruct;&lt;BR /&gt; myStruct.sizes._size1 = 100;&lt;BR /&gt; myStruct.sizes._size2 = 200;&lt;BR /&gt; unsigned char *myStorage=myStruct.buffer+2*sizeof(unsigned int);&lt;BR /&gt; unsigned int myLength = (unsigned int)(sizeof(myStruct.buffer)-sizeof(myStruct.sizes));&lt;/P&gt;
&lt;P&gt;You can use structures with sizes at structure head instead of plain buffer. So, many and many :)&lt;/P&gt;
&lt;P&gt;Regards,&lt;BR /&gt;Sergey&lt;/P&gt;</description>
      <pubDate>Thu, 11 Dec 2008 11:04:30 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Integrated-Performance/Convert-an-int-to-a-byte-array/m-p/888473#M11099</guid>
      <dc:creator>Sergey_K_Intel</dc:creator>
      <dc:date>2008-12-11T11:04:30Z</dc:date>
    </item>
    <item>
      <title>Re: Convert an int to a byte array</title>
      <link>https://community.intel.com/t5/Intel-Integrated-Performance/Convert-an-int-to-a-byte-array/m-p/888474#M11100</link>
      <description>&lt;DIV style="margin:0px;"&gt;
&lt;DIV id="quote_reply" style="margin-top: 5px; width: 100%;"&gt;
&lt;DIV style="margin-left:2px;margin-right:2px;"&gt;Quoting - &lt;A href="https://community.intel.com/en-us/profile/61463"&gt;vdudnik&lt;/A&gt;&lt;/DIV&gt;
&lt;DIV style="background-color:#E5E5E5; padding:5px;border: 1px; border-style: inset;margin-left:2px;margin-right:2px;"&gt;&lt;EM&gt;
&lt;P&gt;With fread you can't specify to read 4-bytes varaible as big-endian or little-endian value. So you have to think on arhitecture you are running on and on format of the data you read (and how to interpret them) by yourself.&lt;/P&gt;
&lt;P&gt;Vladimir&lt;/P&gt;
&lt;/EM&gt;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;&lt;BR /&gt;The point is not to be little-endian or big-endian. I am using Intel architecture and want it as simple as possible.&lt;/P&gt;</description>
      <pubDate>Thu, 11 Dec 2008 17:04:09 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Integrated-Performance/Convert-an-int-to-a-byte-array/m-p/888474#M11100</guid>
      <dc:creator>constantine-vassilev</dc:creator>
      <dc:date>2008-12-11T17:04:09Z</dc:date>
    </item>
    <item>
      <title>Re: Convert an int to a byte array</title>
      <link>https://community.intel.com/t5/Intel-Integrated-Performance/Convert-an-int-to-a-byte-array/m-p/888475#M11101</link>
      <description>&lt;DIV style="margin:0px;"&gt;
&lt;DIV id="quote_reply" style="margin-top: 5px; width: 100%;"&gt;
&lt;DIV style="margin-left:2px;margin-right:2px;"&gt;Quoting - &lt;A href="https://community.intel.com/en-us/profile/408636"&gt;sergey_kh&lt;/A&gt;&lt;/DIV&gt;
&lt;DIV style="background-color:#E5E5E5; padding:5px;border: 1px; border-style: inset;margin-left:2px;margin-right:2px;"&gt;&lt;EM&gt;
&lt;DIV style="margin:0px;"&gt;&lt;/DIV&gt;
&lt;P&gt;Constantine, there are so many ways to implement this... Below is an example with "unsigned int". The same will be with Ipp32u.&lt;/P&gt;
&lt;P&gt;unsigned char buffer[1000];&lt;BR /&gt;unsigned int *size1 = (unsigned int*)buffer;&lt;BR /&gt;unsigned int *size2 = (unsigned int*)(buffer+sizeof(unsigned int));&lt;BR /&gt;*size1 = 100;&lt;BR /&gt;*size2 = 200;&lt;BR /&gt;unsigned char *myStorage=buffer+2*sizeof(unsigned int);&lt;BR /&gt;unsigned int myLength = (unsigned int)(sizeof(buffer)-(myStorage-buffer));&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;You can use memcpy:&lt;BR /&gt;unsigned int size1 = 100;&lt;BR /&gt;unsigned int size2 = 200;&lt;BR /&gt;memcpy(buffer, &amp;amp;size1, sizeof(unsigned int));&lt;BR /&gt;memcpy(buffer+sizeof(unsigned int), &amp;amp;size2, sizeof(unsigned int));&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Exotic:&lt;BR /&gt;union {&lt;BR /&gt;unsigned char buffer[1000];&lt;BR /&gt;struct {&lt;BR /&gt;unsigned int _size1;&lt;BR /&gt;unsigned int _size2;&lt;BR /&gt;} sizes;&lt;BR /&gt;} myStruct;&lt;BR /&gt;myStruct.sizes._size1 = 100;&lt;BR /&gt;myStruct.sizes._size2 = 200;&lt;BR /&gt;unsigned char *myStorage=myStruct.buffer+2*sizeof(unsigned int);&lt;BR /&gt;unsigned int myLength = (unsigned int)(sizeof(myStruct.buffer)-sizeof(myStruct.sizes));&lt;/P&gt;
&lt;P&gt;You can use structures with sizes at structure head instead of plain buffer. So, many and many :)&lt;/P&gt;
&lt;P&gt;Regards,&lt;BR /&gt;Sergey&lt;/P&gt;
&lt;/EM&gt;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;Thanks for the example. The whole point of my question was how easily can READ back the values of Ipp32u&lt;BR /&gt;variable, without intermediate routine. I know there many ways to store the information in memory bytewise, the question is how easily to get it back directly. Because in my application compression is made 1 time, but decopression is made thousand times and each conversion takes time. Microsoft has BitConverter doing this but it is for .NET. the question was does Intel has more efficient procedure for the low level C.&lt;/P&gt;
&lt;P&gt;Here is a code in C#:&lt;/P&gt;
&lt;P&gt;byte[] bytes = { 0, 0, 0, 25 };&lt;BR /&gt;&lt;SPAN style="color: blue;"&gt;int&lt;/SPAN&gt; i = BitConverter.ToInt32(bytes, 0);&lt;/P&gt;
&lt;P&gt;As you see the storage is in byte array, but the BitConverter gets 4 bytes, combines them and returns&lt;BR /&gt;integer.&lt;/P&gt;
&lt;P&gt;Now the question is how to do that most efficiently in Standard C.&lt;/P&gt;
&lt;P&gt;Thanks in advance,&lt;/P&gt;
&lt;P&gt;Konstantin&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Dec 2008 17:12:18 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Integrated-Performance/Convert-an-int-to-a-byte-array/m-p/888475#M11101</guid>
      <dc:creator>constantine-vassilev</dc:creator>
      <dc:date>2008-12-11T17:12:18Z</dc:date>
    </item>
    <item>
      <title>Re: Convert an int to a byte array</title>
      <link>https://community.intel.com/t5/Intel-Integrated-Performance/Convert-an-int-to-a-byte-array/m-p/888476#M11102</link>
      <description>&lt;DIV style="margin:0px;"&gt;Are you looking for routine like this?&lt;/DIV&gt;
&lt;DIV style="margin:0px;"&gt;char a, b, c, d;&lt;/DIV&gt;
&lt;DIV style="margin:0px;"&gt;int abcd;&lt;/DIV&gt;
&lt;DIV style="margin:0px;"&gt;abcd = (a &amp;lt;&amp;lt; 24) | (b &amp;lt;&amp;lt; 16) | (c &amp;lt;&amp;lt; 8) | d&lt;/DIV&gt;
&lt;DIV style="margin:0px;"&gt;or&lt;/DIV&gt;
&lt;DIV style="margin:0px;"&gt; (d &amp;lt;&amp;lt; 24) | (c &amp;lt;&amp;lt; 16) | (b &amp;lt;&amp;lt; 8) | a&lt;/DIV&gt;
&lt;DIV style="margin:0px;"&gt;if you need value in different endianess, (I remember youare not consider this as a question of endianess, but actually it is, might be not explicitely)&lt;/DIV&gt;
&lt;DIV style="margin:0px;"&gt;Vladimir&lt;/DIV&gt;
&lt;DIV style="margin:0px;"&gt;&lt;/DIV&gt;
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Dec 2008 19:39:38 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Integrated-Performance/Convert-an-int-to-a-byte-array/m-p/888476#M11102</guid>
      <dc:creator>Vladimir_Dudnik</dc:creator>
      <dc:date>2008-12-11T19:39:38Z</dc:date>
    </item>
    <item>
      <title>Re: Convert an int to a byte array</title>
      <link>https://community.intel.com/t5/Intel-Integrated-Performance/Convert-an-int-to-a-byte-array/m-p/888477#M11103</link>
      <description>&lt;DIV style="margin:0px;"&gt;
&lt;DIV id="quote_reply" style="margin-top: 5px; width: 100%;"&gt;
&lt;DIV style="margin-left:2px;margin-right:2px;"&gt;Quoting - &lt;A href="https://community.intel.com/en-us/profile/61463"&gt;vdudnik&lt;/A&gt;&lt;/DIV&gt;
&lt;DIV style="background-color:#E5E5E5; padding:5px;border: 1px; border-style: inset;margin-left:2px;margin-right:2px;"&gt;&lt;EM&gt;
&lt;DIV style="margin:0px;"&gt;Are you looking for routine like this?&lt;/DIV&gt;
&lt;DIV style="margin:0px;"&gt;char a, b, c, d;&lt;/DIV&gt;
&lt;DIV style="margin:0px;"&gt;int abcd;&lt;/DIV&gt;
&lt;DIV style="margin:0px;"&gt;abcd = (a &amp;lt;&amp;lt; 24) | (b &amp;lt;&amp;lt; 16) | (c &amp;lt;&amp;lt; 8) | d&lt;/DIV&gt;
&lt;DIV style="margin:0px;"&gt;or&lt;/DIV&gt;
&lt;DIV style="margin:0px;"&gt; (d &amp;lt;&amp;lt; 24) | (c &amp;lt;&amp;lt; 16) | (b &amp;lt;&amp;lt; 8) | a&lt;/DIV&gt;
&lt;DIV style="margin:0px;"&gt;if you need value in different endianess, (I remember youare not consider this as a question of endianess, but actually it is, might be not explicitely)&lt;/DIV&gt;
&lt;DIV style="margin:0px;"&gt;Vladimir&lt;/DIV&gt;
&lt;P&gt;&lt;/P&gt;
&lt;/EM&gt;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;&lt;BR /&gt;I suppose this is in the right direction, how to apply this routine to byte array? Endianness is not a question, it does not matter.&lt;/P&gt;</description>
      <pubDate>Thu, 11 Dec 2008 19:42:26 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Integrated-Performance/Convert-an-int-to-a-byte-array/m-p/888477#M11103</guid>
      <dc:creator>constantine-vassilev</dc:creator>
      <dc:date>2008-12-11T19:42:26Z</dc:date>
    </item>
    <item>
      <title>Re: Convert an int to a byte array</title>
      <link>https://community.intel.com/t5/Intel-Integrated-Performance/Convert-an-int-to-a-byte-array/m-p/888478#M11104</link>
      <description>&lt;DIV style="margin:0px;"&gt;&lt;/DIV&gt;
&lt;P&gt;simple loop might help I believe.&lt;/P&gt;</description>
      <pubDate>Thu, 11 Dec 2008 19:47:22 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Integrated-Performance/Convert-an-int-to-a-byte-array/m-p/888478#M11104</guid>
      <dc:creator>Vladimir_Dudnik</dc:creator>
      <dc:date>2008-12-11T19:47:22Z</dc:date>
    </item>
    <item>
      <title>Re: Convert an int to a byte array</title>
      <link>https://community.intel.com/t5/Intel-Integrated-Performance/Convert-an-int-to-a-byte-array/m-p/888479#M11105</link>
      <description>&lt;DIV style="margin:0px;"&gt;
&lt;DIV id="quote_reply" style="margin-top: 5px; width: 100%;"&gt;
&lt;DIV style="margin-left:2px;margin-right:2px;"&gt;Quoting - &lt;A href="https://community.intel.com/en-us/profile/61463"&gt;vdudnik&lt;/A&gt;&lt;/DIV&gt;
&lt;DIV style="background-color:#E5E5E5; padding:5px;border: 1px; border-style: inset;margin-left:2px;margin-right:2px;"&gt;&lt;EM&gt;
&lt;P&gt;simple loop might help I believe.&lt;/P&gt;
&lt;/EM&gt;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;&lt;BR /&gt;Does Intel has more efficient way of performing Array left shift for example? E.g. having an array(vector) to perform &amp;lt;&amp;lt; on entire vector? This is more efficient than a loop.&lt;/P&gt;</description>
      <pubDate>Thu, 11 Dec 2008 20:13:22 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Integrated-Performance/Convert-an-int-to-a-byte-array/m-p/888479#M11105</guid>
      <dc:creator>constantine-vassilev</dc:creator>
      <dc:date>2008-12-11T20:13:22Z</dc:date>
    </item>
    <item>
      <title>Re: Convert an int to a byte array</title>
      <link>https://community.intel.com/t5/Intel-Integrated-Performance/Convert-an-int-to-a-byte-array/m-p/888480#M11106</link>
      <description>&lt;DIV style="margin:0px;"&gt;How do you estimated efficiency? You probably had try such a shift already? Then you may just continue to use it because of higher efficiency.&lt;/DIV&gt;
&lt;DIV style="margin:0px;"&gt;&lt;/DIV&gt;
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Dec 2008 20:42:19 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Integrated-Performance/Convert-an-int-to-a-byte-array/m-p/888480#M11106</guid>
      <dc:creator>Vladimir_Dudnik</dc:creator>
      <dc:date>2008-12-11T20:42:19Z</dc:date>
    </item>
    <item>
      <title>Re: Convert an int to a byte array</title>
      <link>https://community.intel.com/t5/Intel-Integrated-Performance/Convert-an-int-to-a-byte-array/m-p/888481#M11107</link>
      <description>&lt;DIV style="margin:0px;"&gt;
&lt;DIV id="quote_reply" style="margin-top: 5px; width: 100%;"&gt;
&lt;DIV style="margin-left:2px;margin-right:2px;"&gt;Quoting - &lt;A href="https://community.intel.com/en-us/profile/61463"&gt;vdudnik&lt;/A&gt;&lt;/DIV&gt;
&lt;DIV style="background-color:#E5E5E5; padding:5px;border: 1px; border-style: inset;margin-left:2px;margin-right:2px;"&gt;&lt;EM&gt;
&lt;DIV style="margin:0px;"&gt;How do you estimated efficiency? You probably had try such a shift already? Then you may just continue to use it because of higher efficiency.&lt;/DIV&gt;
&lt;P&gt;&lt;/P&gt;
&lt;/EM&gt;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;&lt;BR /&gt;By efficiency I mean coding efficiency. Codingloops is not a solution, it is much simpler andefficient to code it asthe Intel IPPvector functions do. If there are vector left shift finction for example LeftShift(Src,Dst), I will get all Src vector elements left shifted with just one command.&lt;/P&gt;
&lt;P&gt;By the way I am reading Fixed-Accuracy&lt;BR /&gt;Arithmetic Functions Chapter 12 of Intel IPP Signal Processing. &lt;SPAN style="font-family: Courier;"&gt;&lt;SPAN style="font-family: Courier;"&gt;&lt;SPAN style="font-size: x-small;"&gt;32f is by definition floating point, how they are intepreted as fixed point in Fixed-Accuracy Arithmetic Functions?&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Dec 2008 20:49:18 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Integrated-Performance/Convert-an-int-to-a-byte-array/m-p/888481#M11107</guid>
      <dc:creator>constantine-vassilev</dc:creator>
      <dc:date>2008-12-11T20:49:18Z</dc:date>
    </item>
    <item>
      <title>Re: Convert an int to a byte array</title>
      <link>https://community.intel.com/t5/Intel-Integrated-Performance/Convert-an-int-to-a-byte-array/m-p/888482#M11108</link>
      <description>&lt;DIV style="margin:0px;"&gt;
&lt;DIV id="quote_reply" style="width: 100%; margin-top: 5px;"&gt;
&lt;DIV style="margin-left:2px;margin-right:2px;"&gt;Quoting - &lt;A href="https://community.intel.com/en-us/profile/408384"&gt;thstart&lt;/A&gt;&lt;/DIV&gt;
&lt;DIV style="background-color:#E5E5E5; padding:5px;border: 1px; border-style: inset;margin-left:2px;margin-right:2px;"&gt;&lt;EM&gt;
&lt;DIV style="margin:0px;"&gt;&lt;/DIV&gt;
&lt;P&gt;Because in my application compression is made 1 time, but decopression is made thousand times and each conversion takes time.&lt;/P&gt;
&lt;/EM&gt;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;You may use any of conversion methods, looking only at method's esthetics. This conversion's burden - comparing to compression/decompression times - anyway will be negligible.&lt;/P&gt;</description>
      <pubDate>Fri, 12 Dec 2008 09:11:00 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Integrated-Performance/Convert-an-int-to-a-byte-array/m-p/888482#M11108</guid>
      <dc:creator>Sergey_K_Intel</dc:creator>
      <dc:date>2008-12-12T09:11:00Z</dc:date>
    </item>
    <item>
      <title>Re: Convert an int to a byte array</title>
      <link>https://community.intel.com/t5/Intel-Integrated-Performance/Convert-an-int-to-a-byte-array/m-p/888483#M11109</link>
      <description>&lt;DIV style="margin:0px;"&gt;&lt;EM&gt;&lt;/EM&gt;
&lt;DIV style="margin: 0px;"&gt;&amp;gt;Are you looking for routine like this?&lt;/DIV&gt;
&lt;DIV style="margin: 0px;"&gt;&amp;gt;char a, b, c, d;&lt;/DIV&gt;
&lt;DIV style="margin: 0px;"&gt;&amp;gt;int abcd;&lt;/DIV&gt;
&lt;DIV style="margin: 0px;"&gt;&amp;gt;abcd = (a &amp;lt;&amp;lt; 24) | (b &amp;lt;&amp;lt; 16) | (c &amp;lt;&amp;lt; 8) | d&lt;/DIV&gt;
&lt;DIV style="margin: 0px;"&gt;&amp;gt;or&lt;/DIV&gt;
&lt;DIV style="margin: 0px;"&gt; (d &amp;lt;&amp;lt; 24) | (c &amp;lt;&amp;lt; 16) | (b &amp;lt;&amp;lt; 8) | a&lt;/DIV&gt;
&lt;DIV style="margin: 0px;"&gt;I need the following:&lt;/DIV&gt;
&lt;DIV style="margin: 0px;"&gt;int abcd=1234;&lt;/DIV&gt;
&lt;DIV style="margin: 0px;"&gt;char arr[4];&lt;/DIV&gt;
&lt;DIV style="margin: 0px;"&gt;how the digit 1 from abcd to go to arr[0], the digit 2 to go to arr[1], the digit 3 to go to arr[2] and the digit4 to arr[3].&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Mon, 15 Dec 2008 08:55:48 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Integrated-Performance/Convert-an-int-to-a-byte-array/m-p/888483#M11109</guid>
      <dc:creator>constantine-vassilev</dc:creator>
      <dc:date>2008-12-15T08:55:48Z</dc:date>
    </item>
  </channel>
</rss>

