I am trying to interpret a binary file and unless I put the bits in the rught position and read it as a float, the numbers mean nothing. I know what order they should go in but I don't know what eah number is, so dividing by anything won't work.
Her's the code I have so far, but the convertion from tempValue to Value doesn't work at all. It spits out an incorrect int, loosing all the decimal places.
Thanks for the replies so far.
Code:
# include <stdio.h>
# define BYTE21 0X0000ffff
# define BYTE43 0Xffff0000
int
main (void)
{
FILE *inp;
float Value;
long TempValue;
long new21, new43;
inp = fopen("test_outp.baf", "rb");
if(!inp)
printf("The file could not be opened.\n");
fseek(inp, sizeof(char)*3116,SEEK_SET);
fread(&TempValue,sizeof(long),1,inp);
new21 = (TempValue & BYTE21) << 16;
new43 = (TempValue & BYTE43) >> 16;
TempValue = new21 | new43;
Value = TempValue;
printf("%f \n", Value);
return (0);
}