[c언어] 4바이트 배열을 float로 변환하는데 잘 안됩니다..

조회수 2101회
for(i = 0; i<3; i++)
   {
         //PM_int[i] = (iobyte[i][0] << 24) & 0xff000000;
         //PM_int[i] |= (iobyte[i][1] << 16) & 0x00ff0000;
         //PM_int[i] |= (iobyte[i][2] << 8) & 0x0000ff00;
         //PM_int[i] |= (iobyte[i][3]) & 0x000000ff;
         PM_int[i] = ((byte)iobyte[i][0]<<24)|((byte)iobyte[i][1]<<16)|((byte)iobyte[i][2]<<8)|((byte)iobyte[i][3]);
         PM[i] = (float)PM_int[i];
   }
   #ifdef COMMUNICATION_TEST_MODE
   printf ("%x%x%x%x\r\n",iobyte[0][0],iobyte[0][1],iobyte[0][2],iobyte[0][3]);
   printf ("%x%x%x%x\r\n",iobyte[1][0],iobyte[1][1],iobyte[1][2],iobyte[1][3]);
   printf ("%x%x%x%x\r\n",iobyte[2][0],iobyte[2][1],iobyte[2][2],iobyte[2][3]);
   printf ("%f,%f,%f\r\n", PM[0],PM[1],PM[2]);

현재 iobyte[][] 에는

11 / FE / 95 / 42

AA / 33 / AD / 42

FD / 11 / AF / 42

가 출력되어 나오는데..

PM[] 에는

66.00 / 66.00 / 66.00

같은 값만 출력이 되네요.. 도와주세요..ㅠ

  • (•́ ✖ •̀)
    알 수 없는 사용자

답변을 하려면 로그인이 필요합니다.

프로그래머스 커뮤니티는 개발자들을 위한 Q&A 서비스입니다. 로그인해야 답변을 작성하실 수 있습니다.

(ಠ_ಠ)
(ಠ‿ಠ)