|
I am running into this same problem now. Did anyone ever figure out a solution?
Thanks,
Sarah
"Philip Arcuni" wrote in message <h6she1$5h7$1@fred.mathworks.com>...
> I am creating binary files for a camera where 3 by 21-bit data are stored in 64 bit words.
>
> My code creates uint64 words which parse correctly.
>
> However, when I write these uint64 words, and then read them, they are not correct.
>
> For example, if I create a uint64 word (using bitshift and bitor) which reports as
> q =
>
> 9147373404693901452
>
> (note that this *can't* naively be entered in Matlab as q = uint64(9147373404693901452) because of the precision limitations of double precision numbers)
> then issue the following fwrite and fread:
>
> fid = fopen('test.hex','w');fwrite(fid,q,'uint64'),fclose(fid);
> fid = fopen('test.hex','r');t = fread(fid,'uint64=>uint64'),fclose(fid)
>
> I get
> t =
>
> 9147373404693901312
>
> Not sure if the error is in the write or the read (I fear the write), but it does appear related to an invisible intermediate double precision step.
>
> Is there any advice as to a fix or an elegant solution/work around?
|