Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
32 ビット配列を 16 ビット配列にコピーする最良の方法は何ですか?
「memcpy」がハードウェア命令を使っていることは知っていますが、要素ごとに「サイズを変えて」配列をコピーする標準機能はありますか?
armv7 (cortex A8) には gcc を使用しています。
uint32_t tab32[500]; uint16_t tab16[500]; for(int i=0;i<500;i++) tab16[i]=tab32[i];
これを行う標準関数はありません。これは主に、アプリケーションに非常に固有であるためです。
の整数がtab32uint16_t に収まるほど小さいことがわかっている場合、質問のコードはおそらく取得できる最高のものです (何かを最適化できる場合、コンパイラは残りを行います)。
tab32